Built-In Namespace Array
| Method Attributes | Method Name and Description |
|---|---|
|
each(unitFunction, recursive)
Applies the given unitFunction to each element in the array and replaces it with the result.
|
|
|
indexOf(element, strictMatch, startFrom)
Finds the index of the given element int the array.
|
|
|
pad(newLength, value)
Pads the array to the given length appending the given value to the end of the string iteratively.
|
|
|
product(recursive)
Multiplies all the elements in the array.
|
|
|
rand(count)
Returns the given number of randomly selected elements from the array.
|
|
|
reduce(unitFunction, initialValue, recursive)
Recursively reduces the array to a single value using the given unitFunction.
|
|
|
shuffle()
Shuffles the array and returnes the shuffled version.
|
|
|
sum(recursive)
Sums all the elements in the array.
|
Method Detail
{Array}
each(unitFunction, recursive)
Applies the given unitFunction to each element in the array and replaces it with the result.
Defined in: aV.ext.array.js.
Defined in: aV.ext.array.js.
- Parameters:
- {Function(x)} unitFunction
- The unit function which will be applied to the elements
- {Boolean} recursive Optional, Default: false
- Indicates wheter the function should be applied to possible sub-elements.
- Returns:
- {Array} Returns the modified array, a.k.a itself.
{Integer}
indexOf(element, strictMatch, startFrom)
Finds the index of the given element int the array.
Returns -1 if there is no match
Defined in: aV.ext.array.js.
Defined in: aV.ext.array.js.
- Parameters:
- {Object} element
- The element whose index should be found.
- {Boolean} strictMatch Optional, Default: false
- Indicates wheter the comparison would be type sensitive (uses === comparator)
- {Integer} startFrom Optional, Default: 0
- Where to start searching from
- Returns:
- {Integer} The index of the found element or -1
{Array}
pad(newLength, value)
Pads the array to the given length appending the given value to the end of the string iteratively.
Defined in: aV.ext.array.js.
Defined in: aV.ext.array.js.
- Parameters:
- {Integer} newLength
- {Object} value
- Returns:
- {Array} Returns the new version of itself.
{Number}
product(recursive)
Multiplies all the elements in the array.
Defined in: aV.ext.array.js.
Defined in: aV.ext.array.js.
- Parameters:
- {Boolean} recursive Optional, Default: false
- Defines wheter the function should go into sub-arrays to multiply.
- Returns:
- {Number} The product of all the items in the arrray and possible sub-arrays according to recursive parameter.
{Object|Array}
rand(count)
Returns the given number of randomly selected elements from the array.
The items may repeat since there is no check a uniqueness test on the result.
Defined in: aV.ext.array.js.
Defined in: aV.ext.array.js.
- Parameters:
- {Integer} count Optional, Default: 1
- Returns:
- {Object|Array} Returns the randomly selected elements from the array. If count is 1 the result is not an array but the picked element itself.
{Object}
reduce(unitFunction, initialValue, recursive)
Recursively reduces the array to a single value using the given unitFunction.
To understand how reduce exactly works, see PHP array_reduce at http://php.net/array_reduce
Defined in: aV.ext.array.js.
Defined in: aV.ext.array.js.
- Parameters:
- {Function(x|y)} unitFunction
- {Object} initialValue Optional, Default: null
- {Boolean} recursive Optional, Default: false
- Returns:
- {Object} The reduced value.
{Array}
shuffle()
Shuffles the array and returnes the shuffled version.
Defined in: aV.ext.array.js.
Defined in: aV.ext.array.js.
- Returns:
- {Array} The new, shuffled array.
{Number}
sum(recursive)
Sums all the elements in the array.
Defined in: aV.ext.array.js.
Defined in: aV.ext.array.js.
- Parameters:
- {Boolean} recursive Optional, Default: false
- Defines wheter the function should go into sub-arrays to sum.
- Returns:
- {Number} The sum of all the items in the arrray and possible sub-arrays according to recursive parameter.