What is the easiest way to insert a new object into an array of objects at the index position 0? No jQuery; MooTools okay; no unshift() because it’s undefined in IE according to w3schools.
What is the easiest way to insert a new object into an array of
Share
W3CSchools is really outdated, the
unshiftmethod is part of the ECMAScript 3rd Edition standard which was approved and published as of December 1999.There is no reason to avoid it nowadays, it is supported from IE 5.5 up.
It is safe to use it, even modern libraries like jQuery or MooTools internally use it (you can check the source code :).
This method returns the new array length, and inserts the element passed as argument at the first position of the array.