slice
Make a copy of a part of a DefineList.
list.slice([start[, end]])
slice
creates a copy of a portion of the DefineList.
var list = new DefineList(['Alice', 'Bob', 'Charlie', 'Daniel', 'Eve']);
var newList = list.slice(1, 4);
newList //-> DefineList['Bob', 'Charlie', 'Daniel']
Parameters
- start
{Number}
:The index to start copying from. Defaults to
0
. - end
{Number}
:The first index not to include in the copy If end is not supplied,
slice
will copy until the end of the list.
Use
slice
is the simplest way to copy a DefineList:
var list = new DefineList(['Alice', 'Bob', 'Eve']);
var copy = list.slice();
copy //-> DefineList['Alice', 'Bob', 'Eve']
list === copy; //-> false