Interface JSArrayFunctions
- All Superinterfaces:
JSObjectFunctions
- All Known Subinterfaces:
JS5ArrayFunctions
-
Method Summary
Modifier and TypeMethodDescriptionfunction concat(args) creates and returns a new array that is the result of concatenating each of its arguments to an array.function join(separator) converts each element of the array into a string.pop()function pop() removes and returns the last element of an array.voidfunction push(args) append elements to an array.reverse()function reverse() reverse the elements of an array.shift()function shift() shift array elements down.function slice(start, end) return a portion of an arraysort(JSFunction function) function sort(function) sort the elements of an arrayfunction splice(start, deletecount, items) insert, remove, or replace array elementsfunction unshift(items) insert elements at the beginning of an arrayMethods inherited from interface org.fife.rsta.ac.js.ecma.api.ecma3.functions.JSObjectFunctions
hasOwnProperty, isPrototypeOf, propertyIsEnumerable, toLocaleString, toString, valueOf
-
Method Details
-
concat
function concat(args) creates and returns a new array that is the result of concatenating each of its arguments to an array.Example
var c = [1,2,3]; c.concat(4,5); //Returns [1,2,3,4,5] c.concat([4,5]); //Returns [1,2,3,4,5] c.concat(4,[5,[6, 7]]); //Returns [1,2,3,4,5, [6,7]]
- Parameters:
args- Any number of values to be concatenated to an array.- Since:
- Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
- See Also:
-
join
function join(separator) converts each element of the array into a string. Uses the separator between the elements.Example
var a = [1,2,3]; var s = a.join("|"); //s is the string "1|2|3"- Parameters:
separator- An optional character or string used to separate each element with the string.- Since:
- Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
- See Also:
-
pop
JSObject pop()function pop() removes and returns the last element of an array.Example
var stack = [1,2,3]; stack.pop(); // returns 3, stack [1, 2] stack.pop(); // returns 2, stack [1] stack.pop(); // returns 1, stack []
- Since:
- Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
- See Also:
-
push
function push(args) append elements to an array.Example
var vals = []; vals.push(1,2,3); // returns new array [1,2,3]
- Parameters:
array- One or more values to be appended to the end of the array.- Since:
- Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
- See Also:
-
reverse
JSArray reverse()function reverse() reverse the elements of an array.Example
var r = [1,2,3]; r.reverse(); // r is now [3,2,1]
- Since:
- Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
- See Also:
-
shift
JSObject shift()function shift() shift array elements down.Example
var s = [1,2,3]; s.shift(); // Returns 1; s = [2,3] s.shift(); // Returns 2; s = [3]
- Since:
- Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
- See Also:
-
slice
function slice(start, end) return a portion of an arrayExample
var s = [1,2,3,4,5]; s.slice(0,3); // Returns [1,2,3] s.slice(3); // Returns [4,5] s.slice(1,-1); // Returns [2,3,4]
- Parameters:
start- The array index from where to begin. If negative, this argument specifies a position measured from the end of the array.end- The array index immediately after the end of the slice. If not specified then the slice includes all the array elements from the start to the end of the array.- Since:
- Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
- See Also:
-
sort
function sort(function) sort the elements of an arrayExample
function numbersort(a,b) {return a-b;} var s = new Array(22,1111,33,4,55]); s.sort(); //Alphabetical order : 1111,22,33,4,55 s.sort(numbersort); //Numerical order : 4, 22, 33, 55, 1111- Parameters:
function- an optional function used to specify the sorting order- Since:
- Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
- See Also:
-
splice
function splice(start, deletecount, items) insert, remove, or replace array elementsExample
var s = [1,2,3,4,5,6,7,8]; s.splice(1,2); //Returns [2,3]; s is [1,4] s.splice(1,1); //Returns [4]; s is [1] s.splice(1,0,2,3); //Returns []; s is [1 2 3]
- Parameters:
start- the array element at which the insertion and/or deletion is to begindeletecount- The number of elements starting with and including start.items- zero or more items to be inserted into the array- Since:
- Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
- See Also:
-
unshift
function unshift(items) insert elements at the beginning of an arrayExample
var s = []; s.unshift(1,2); //Returns 2; s is [1,2] s.unshift(22); //Returns 3; s is [22,1,2] s.shift(); //Returns 22; s is [1,2]
- Parameters:
value- One or more values to insert at the beginning of the array- Since:
- Standard ECMA-262 3rd. Edition, Level 2 Document Object Model Core Definition.
- See Also:
-