What\'s the real difference between declaring an array like this:
var myArray = new Array();
and
var myArray = [];
<
For more information, the following page describes why you never need to use new Array()
You never need to use
new Object()in JavaScript. Use the object literal{}instead. Similarly, don’t usenew Array(), use the array literal[]instead. Arrays in JavaScript work nothing like the arrays in Java, and use of the Java-like syntax will confuse you.Do not use
new Number,new String, ornew Boolean. These forms produce unnecessary object wrappers. Just use simple literals instead.
Also check out the comments - the new Array(length) form does not serve any useful purpose (at least in today's implementations of JavaScript).