It’s safer to use []
than it is to use new Array()
, because you can actually override the value of Array
in JavaScript:
Array = function() { };
var x = new Array();
// x is now an Object instead of an Array.
In other words, []
is unambiguous.