My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
insert  
Overview of insert
Updated Jun 21, 2010 by matr...@mac.com

insert

Action that inserts an item (or set of items) into another.

Usage

objx( object ).insert( index, items );

object The item to insert into
index The magic index position denoting where to insert the items
items A single item (or array of items) to insert into object

  • insert is an obstructive plugin

Example

var a = [1,2,4,5];
var b == objx(a).insert(2, 3).obj();

// b == [1,2,3,4,5]

Inserting at the end

insert does not support inserting items to the end of an array or string, instead consider the append plugin.

The following code will add items before the last item:

var a = ["I","like","to","say","World"];
objx(a).insert(-1, "Hello");
// a = ["I","like","to","say","Hello","World"]

Sign in to add a comment
Powered by Google Project Hosting