Next: sort
Up: Methods
Previous: shift
Contents
slice
Description
Extracts a slice or a substring of the array and returns it as a
new array without modifying the original array. The returned array
includes the start element and all elements up to, but not including,
the end element.
Syntax
array1.slice(start, end)
Parameters
- start
- A number specifying
the index of the starting point for the slice. If start is a negative
number, the starting point begins at the end of the array, where -1
is the last element.
- end
- A number specifying
the index of the ending point for the slice. If you omit this parameter,
the slice includes all elements from the start to the end of the array.
If end is a negative number, the ending point is specified from the
end of the array, where -1 is the last element.
Returns
Nothing.
Example
a = new Array("a", "b", "c",
"d", "e", "f", "g", "h");
trace(a.slice(1, 3));
//output: b,c
Copyright ©2000-2010 Shanghai TopCMM Software Technologies. All Rights Reserved.