Class Arr
Utility for Arrays
Defined in: array.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Arr()
|
Field Attributes | Field Name and Description |
---|---|
<static> |
Arr.cloneArray
Clone an array.
|
<static> |
Arr.extendArray
|
<static> |
Arr.isArray
|
<static> |
Arr.keys
|
<static> |
Arr.merge
Merge together two arrays, sort the result, and eliminate any duplicates.
|
<static> |
Arr.sliceArray
Returns a shallow copy of a portion of an array.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
Arr.arrayInsert(array, index, other)
insert elements at a specific index
NOTE: that method modifies the array passed as the first parameter
|
<static> |
Arr.isArrayLike(obj)
Returns true if the given object is an Array or an Array-Like object
|
<static> |
Arr.remove(list, item)
Removes an item from an array or an array-like object
|
<static> |
Arr.removeAll(list, item)
Same as Arr.remove but removes all the occurences of item
|
<static> |
Arr.sortUnique(arr, sortFunc)
Sorts an array and eliminate duplicates from it.
|
<static> |
Arr.unique(arr, sorted)
Filters out unique values of an array, saving only the first occurrence of
every value.
|
<static> |
Arr.values(map)
Returns the values of an object
|
Field Detail
<static>
Arr.cloneArray
Clone an array. If a function is given as second parameter, the function is called for each
elements of the passed array and the results are put in the new one.
- Deprecated:
- Use either Array.slice(array) or Array.map(array, fn) instead. see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array
<static>
Arr.extendArray
- Deprecated:
- Use Array.concat(array, array2) or array.concat(array2) instead
<static>
Arr.isArray
- Deprecated:
- use Array.isArray instead
<static>
Arr.keys
- Deprecated:
- Use Object.keys instead see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys
<static>
Arr.merge
Merge together two arrays, sort the result, and eliminate any duplicates.
- Deprecated:
- use Arr.sortUnique and/or Array.prototype.concat instead
<static>
Arr.sliceArray
Returns a shallow copy of a portion of an array.
- Deprecated:
- use Array.prototype.slice instead
Method Detail
<static>
Arr.arrayInsert(array, index, other)
insert elements at a specific index
NOTE: that method modifies the array passed as the first parameter
- Parameters:
- {Array or Array-Like object} array
- The array in which we insert elements
- {Integer} index
- The index
- {Array or Array-Like object} other
- The elements to insert
- Returns:
- the updated array
<static>
Arr.isArrayLike(obj)
Returns true if the given object is an Array or an Array-Like object
- Parameters:
- {*} obj
- The object
- Returns:
- true if it is an array-like object or false otherwise
<static>
Arr.remove(list, item)
Removes an item from an array or an array-like object
- Parameters:
- {Array or Array-Like object} list
- The array
- {*} item
- The item to remove from the object
- Returns:
- true if an item as been removed, false otherwise
<static>
Arr.removeAll(list, item)
Same as Arr.remove but removes all the occurences of item
- Parameters:
- {Array or Array-Like object} list
- The array
- {*} item
- The item to remove from the object
- Returns:
- true if an item as been removed, false otherwise
<static>
{Array}
Arr.sortUnique(arr, sortFunc)
Sorts an array and eliminate duplicates from it.
- Parameters:
- {Array or Array-Like object} arr
- The array
- {function} sortFunc
- The function used to sort the array (optional)
- Returns:
- {Array} the sorted array
<static>
{Array}
Arr.unique(arr, sorted)
Filters out unique values of an array, saving only the first occurrence of
every value. In case the array is sorted, a faster path is taken.
- Parameters:
- {Array or Array-Like object} arr
- The array
- {Boolean} sorted
- If set to true, use the faster path
- Returns:
- {Array} the array deprived of duplication
<static>
{Array}
Arr.values(map)
Returns the values of an object
- Parameters:
- {*} map
- The object
- Returns:
- {Array} the values