Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

11
  • 18
    To insert multiple items you can use Array.prototype.insert = function (index, items) { this.splice.apply(this, [index, 0].concat(items)); } Commented May 30, 2014 at 12:15
  • 12
    The problem with adding stuff to array is that the function will show up as an element when you do for(i in arr) {...} Commented Jul 2, 2014 at 9:38
  • 29
    But keep in mind that it's not recommended to extend native types since it might interfere with other code or future functionality. Commented Aug 21, 2018 at 9:48
  • 107
    Don’t modify objects you don’t own Commented Feb 19, 2019 at 18:09
  • 44
    Don't modify prototypes Commented May 31, 2019 at 12:54

lang-js