Array Class
Set of functions that deal with arrays.
Item Index
Methods
- binaryFind static
- binaryIndexOf static
- find static
- indexOf static
- unique static
Methods
binaryFind
-
arr
-
compareFcn
Given a function which takes one argument and returns 1, 0, or -1, returns the first element which causes the given function to return 0.
Returns:
the index of the element that causes the given function to return 0, returns -1 if no such element exists
binaryIndexOf
-
arr
-
compareFcn
Given a function which takes one argument and returns 1, 0, or -1, returns the first element which causes the given function to return 0.
Returns:
the index of the element that causes the given function to return 0, returns -1 if no such element exists
find
-
arr
-
predicate
-
scope
Returns the first element in the given array that satisfies the given predicate. Returns null if no element in the given array satisfies the given predicate.
EXAMPLE
var array = [1, 2, 3, 4]
find(array, function(a_number) { return a_number === 2 }); -> 2
find(array, function(a_number) { return a_number === 5 }); -> null
Parameters:
Returns:
first elemtn that satisfies the given preidcate; null
if no such element is found
indexOf
-
arr
-
predicate
-
scope
Returns the index of the first element in the given array that satisfies the given predicate. Returns -1 if no element in the given array satisfies the predicate.
Parameters:
Returns:
index of the first element that satisfied the predicate; -1
if no such element is found