Intellisense pretty much stops working as soon as I call function “meanValue”
I think I narrowed it down but I can’t quite figure it out. Apparently there is something wrong with the function “meanValue” because after I call it within another function, all forms of intellisense stop working…Here is my code. Intellisense doesnt work for everything inside function test after I call the meanValue function…
I have no clue the meanValue function seems fine to me??
//
EDIT: I’ve narrowed it down. Apparently any function where I have If(arr[0].length) type of syntax, it pretty much fails. One thing to note that is the functions run fine and debug fine but for some reason intellisense doesnt like this.
Anyone know what another way to check if something is defined or not? I want to check to see what kind of array I am looking at, if its a multidimensional array or not.
Thanks!!!
//
<script language="javascript" type="text/javascript">
function meanValue(arr) {
var mean;
var sum = 0;
if (arr[0].length) {
for (var j = 0; j < arr[0].length; j++) {
sum += arr[0][j];
}
mean = (sum) / arr[0].length;
}
else {
for (var i = 0; i < arr.length; i++) {
sum += arr[i];
}
mean = (sum) / arr.length;
}
return mean;
}
function test(a, b) {
var testing = 5;
var oranges = meanValue(a);
}
var a = [1, 3, 4];
var b = [4, 5, 6];
</script>
I was able to reproduce the issue in my Netbeans.
The problem seems to stem from a mixing of two languages in one file for certain IDEs. (Is this a .php file with some Javascript in it?)
For some reason, the IDE intellisense engine is trying to parse the less-than (<) symbol in that chunk of code as if it were trying to validate XML, which Javascript isn’t. So, of course, it’s failing.
Try wrapping that code in [CDATA — it should resolve the issue.
So the example above, modified, would be: