I’ve got a javascript file (.js) that I’m editing in Eclipse (Juno). It’s giving me this warning:
Type mismatch: cannot convert from Number to ___anonymous6554_6555
on the return line of this code (this is a simplified example, but it still shows the error):
function foo() {
var temp = {};
if (true) {
temp = 1;
}
return temp;
}
If I change it to:
function foo() {
var temp = new Object();
if (true) {
temp = 1;
}
return temp;
}
the warning goes away, but then jsHint warns me to use object literal notation. Grrr…
Any ideas where that might be coming from? The warning looks like a java warning to me….
EDIT
This is Eclipse’s fault. Take a look at this similar question: Why does Eclipse sometimes warn about arrays of arrays in JavaScript?
I’d ignore the warning (the Java warning), and use
{}.