Source code

CERNY.js.Array

Some useful methods for the Array prototype.

Uses

None

Functions

map

Map an array onto another array based on func.

func : the function that should be applied to all elements of this array
return : an array of the results of the applications of func to the items of this array
append

Append array to this array.

array : the array to append
filter

Filter this array through predicate.

predicate : the predicate to apply to all items of array
return : a new array containing all items that return true on application of predicate
copy

Copy this array.

return : a copy of this array
indexOf

Figure out the index of item in array based on cmpFunc.

item : the item to look for in this array
cmpFunc : the function to use to decide on identity
return : the index of the position of item in this array or -1, if item is not in this array.
contains

Figure out whether item is contained in this array.

item : the item to look for in this array
cmpFunc : the function to use to decide on identity
return : true if x is in this array, false otherwise
remove

Remove item from this array.

item : the item to remove
cmpFunc : the function to use to decide on identity
replace

Replace an item in an array.

replaced : the item to be replaced
replacing : the item to take the position of the replaced
cmpFunc : the function to use to decide on identity
isSubArray

Figure out whether array is a sub array of this array based on cmpFunc.

array : the array that is checked whether it's a sub array
cmpFunc : the function to use to decide on identity
return : true, if there is no item in array that is not in this array, false otherwise

History

2007-01-06 : Added interception.
2006-12-09 : Fixed bug in contains.
2006-12-08 : Fixed bug in append.
2006-07-26 : Created.

API Documentation for version

1.1

Scripts