Interface JSArrayFunctions
-
- All Superinterfaces:
JSObjectFunctions
- All Known Subinterfaces:
JS5ArrayFunctions
public interface JSArrayFunctions extends JSObjectFunctions
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description JSArrayconcat(JSArray args)function concat(args) creates and returns a new array that is the result of concatenating each of its arguments to an array.JSStringjoin(java.lang.String separator)function join(separator) converts each element of the array into a string.JSObjectpop()function pop() removes and returns the last element of an array.voidpush(JSArray array)function push(args) append elements to an array.JSArrayreverse()function reverse() reverse the elements of an array.JSObjectshift()function shift() shift array elements down.JSArrayslice(java.lang.Number start, java.lang.Number end)function slice(start, end) return a portion of an arrayJSArraysort(JSFunction function)function sort(function) sort the elements of an arrayJSArraysplice(JSNumber start, JSNumber deletecount, JSArray items)function splice(start, deletecount, items) insert, remove, or replace array elementsJSNumberunshift(JSArray value)function unshift(items) insert elements at the beginning of an array-
Methods inherited from interface org.fife.rsta.ac.js.ecma.api.ecma3.functions.JSObjectFunctions
hasOwnProperty, isPrototypeOf, propertyIsEnumerable, toLocaleString, toString, valueOf
-
-
-
-
Method Detail
-
concat
JSArray concat(JSArray args)
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:
Array
-
join
JSString join(java.lang.String separator)
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:
Array
-
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 []
-
push
void push(JSArray array)
function push(args) append elements to an array.Example
var vals = []; vals.push(1,2,3); // returns new array [1,2,3]
-
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:
Array
-
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]
-
slice
JSArray slice(java.lang.Number start, java.lang.Number end)
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:
Array,splice();
-
sort
JSArray sort(JSFunction function)
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:
Array
-
splice
JSArray splice(JSNumber start, JSNumber deletecount, JSArray items)
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:
Array,shift();
-
-