views:

41

answers:

1
+2  Q: 

Javascript Array

i want to use javascript array globly using netbeans ide.. i declare the array like this.layer=new Array(); and var layer=new Array(); but the problem is that when i use the array in function the drop down menu of Array functions is not shown as netbeans shows.

+1  A: 

Type analysis for a fully-dynamic language like JavaScript is tricky and there's no guarantee an IDE will be able to resolve it. Autocompletion is very much a best-guess feature. I wouldn't expect tracking properties like this.layer to work as, unless it enforces one particular style of object creation there is no way for an IDE to know what this is.

I would suggest in general using the array literal syntax [] in preference to new Array in almost every case. Don't know if that'll help Netbeans though.

bobince
`[]` instead of `new Array` is highly recommended for JavaScript.
Yorirou