JSL.array

Handles all the array related functions.

JLS.array Code

Arguments

 * array
 * The array on which the operation must be done.

JSL.array.map( func[, user_args ] )
This function will loop thru the array and call the given function for each element. The values returned by the user defined function will be used to create a new array/object that is returned by the function at the end. 3 arguments will be passed to the user defined function - - current_item - The value of the current element - index - The index we are currently at   - full_array - The entire array - user_args - The data provided by the user, if any.

Arguments

 * func
 * The user function.


 * user_args
 * Custom data passed into the function
 * Optional Argument

Example
Result will be [5, 11, 66]

Result will be [9, 15, 70] - 5, the second argument of the map function is passed into the 1st argument function.

JSL.array.each( func[, user_args ] )
This function will loop thru the array and call the given function for each element. 4 arguments will be passed to the user defined function - current_item - The value of the current element index - The index we are currently at   full_array - The entire array user_args - The data provided by the user, if any, as an arrayIf the user function returns anything, the loop will end - returning that value to the calling code.

Arguments

 * func
 * The user function.


 * user_args
 * Custom data passed into the function
 * Optional Argument

JSL.array.filter( func[, user_args ] )
Function will loop thru the array and collects all the element for which the user function returned a true value. This array will be returned as a JSL.array object.

Arguments

 * func
 * The user function.


 * user_args
 * Custom data passed into the function.
 * Optional Argument

JSL.array.indexOf
Searches thru the array until the given element is found - and returns it index.

Arguments

 * The value that must be searched for.
 * The value that must be searched for.

Returns
-1 if searched element was not found - or it will return the index of the first found element.

JSL.array.reduce( func, initial_value )
Apply a function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value. Taken from : http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:reduce

Arguments

 * func
 * The Function


 * initial_value
 * The Initial Value

Returns
The Result

JSL.array.grep( regexp )
Returns all the elements in the selected array that matches the provided regular expression

Arguments

 * regexp
 * The regular expression that should be matched against all the elements in the array.

JSL.array.getSize
Get the number of elements currently seleted.

Returns
length(Integer) - The size of the currently selected array

JSL.array.get
Returns the base element - in this case, an array.

JSL.array.isList
Checks wether the current array is an Numerical Array(List) - if so return true. Objects return false.

Returns
Boolean - true if its an numerical array(list) and false if its anything else