Use of new keywords
In addition to instantiating an object or a rare case where data needs to be loaded at a time delay, you basically do not need to use the new keyword. Allocating a large number of new variable addresses in Javascript is a very slow operation. For efficiency, you should always use object symbols.
New array () Will instantiate an object variable, and VAR arr = [], so it directly declares a variable. Obviously, the performance loss of an instance object is greater than that of an object directly declared.
The only difference in syntax between [] and new array () is that new array () can directly set the length of the array.
For example, new array (100)
However, this feature often brings little trouble to program modification.
For example, new array (56,46, 78) sets three elements for the array at the beginning, and then removes the two elements for modifying the program for a certain reason. If you don't pay attention to it, it becomes new array (56 ). Cause program errors.
Arr = [] when creating an object, it will allocate the default number of elements, that is, even if you only put one element in it, it will occupy the space of the default number of elements, when the number of elements exceeds the limit,
New space will be allocated again.
This is generally used when the number of elements is not determined. In theory, it is suspected of wasting memory space (it will occupy the vast majority if it is not used completely ).
New array ()
When creating an object, the number of elements has been determined. When the number of elements is known, the number of elements is more limited, but more "energy-saving ".
VaR arr = [] and VAR arr = new array ();