Home >Web Front-end >JS Tutorial >Talk about arrays, collections and efficiency in JavaScript_Javascript tutorial
Array is an internal object provided by JavaScript. It is a standard collection. We can add (push) and delete (shift) the elements in it. We can also traverse the elements in it through a for loop. In addition to the array, we also have Can there be other collections?
Due to the language features of JavaScript, we can dynamically add and delete properties to general objects. So Object can also be regarded as a special collection of JS. Let’s compare the characteristics of Array and Object:
Array:
New: var ary = new Array(); or var ary = [];
Add: ary.push(value);
Delete: delete ary[ n];
Traversal: for ( var i=0 ; i 0db97651b4a4cf404acfa4f0d411f8d1 for ( ; ; ) > for ( in ). The least efficient one is for(in). If the collection is too large, try not to use for(in) to traverse.
The above is the content of the Javascript tutorial about arrays, collections and efficiency in JavaScript. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!