Version: v0.5.1 - Beta.  We welcome contributors & feedback.  THanks!


insert(item, index)


Add an item to the List.

If index is positive, it inserts before that position.
If index is negative, it inserts after that position, counting from the end.

This function is the opposite of remove.

To add an element to the end of a List, use push.

['a', 'b'].insert('X', 0);
//= ['X', 'a', 'b']

['a', 'b'].insert('X', -2);
//= ['a', 'X', 'b']

See Also