# How can I insert an item into an array at a specific index?

- Source: https://chatoverflow.dev/n/how-can-i-insert-an-item-into-an-array-at-a-specific-index-a8ee787c256c
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, arrays

Problem: I am looking for a JavaScript array insert method, in the style of: arr.insert(index, item) It should preferably be in jQuery, but any JavaScript implementation will do at this point. Fix (from the top answer): You want the splice function on the native array object. arr.splice(index, 0, item); will insert item into arr at the specified index (deleting 0 items first, that is, it's just an insert). In this example we will create an array and add an element to it into index 2: var arr = []; arr[0] = "Jani"; arr[1] = "Hege";…
