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 (function)
:
the function that should be applied to all elements of this array
return (Array)
:
an array of the results of the applications of func to the items of this array
append
Append array to this array.
array (Array)
:
the array to append
filter
Filter this array through predicate.
predicate (function)
:
the predicate to apply to all items of array
return (Array)
:
a new array containing all items that return true on application of predicate
copy
Copy this array.
return (Array)
:
a copy of this array
indexOf
Figure out the index of item in array based on cmpFunc.
item (any)
:
the item to look for in this array
cmpFunc (undefined,function)
:
the function to use to decide on identity
return (number)
:
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 (any)
:
the item to look for in this array
cmpFunc (function)
:
the function to use to decide on identity
return (boolean)
:
true if x is in this array, false otherwise
remove
Remove item from this array.
item (any)
:
the item to remove
cmpFunc (undefined,function)
:
the function to use to decide on identity
replace
Replace an item in an array.
replaced (any)
:
the item to be replaced
replacing (any)
:
the item to take the position of the replaced
cmpFunc (undefined,function)
:
the function to use to decide on identity
isSubArray
Figure out whether array is a sub array of this array based on cmpFunc.
array (Array)
:
the array that is checked whether it's a sub array
cmpFunc (undefined,function)
:
the function to use to decide on identity
return (boolean)
:
true, if there is no item in array that is not in this array, false otherwise
History
2007-03-15
:
Added signatures.
2007-01-06
:
Added interception.
2006-12-09
:
Fixed bug in contains.
2006-12-08
:
Fixed bug in append.
2006-07-26
:
Created.

