JavaScript Array related methods
Methods
-
static compare(array1, array2, floatPrecisionopt) → {boolean}
-
Compares two arrays.
The items in the arrays must be compatible with the == operandParameters:
Name Type Attributes Default Description array1
Array | Collection The array array2
Array | Collection The array floatPrecision
int <optional>
-1 The precision for (float) number comparison, number of decimals. Set to -1 to not use. Returns:
boolean - true if the two arrays contain the same values -
static getDuplicates(arr) → {Array}
-
Returns all duplicated values found in the array
Parameters:
Name Type Description arr
Array The array Returns:
Array - The duplicated values -
static hasDuplicates(arr) → {boolean}
-
Checks if the array has duplicate values
Parameters:
Name Type Description arr
Array The array Returns:
boolean - true if the array has duplicate values -
static indexOf(arr, value, comparisonFunctionopt) → {int}
-
Gets the first index of a value in an Array, or -1 if not found
Parameters:
Name Type Attributes Description arr
Array The array value
* The value to find. Must be compatible with the == operand, or provide a comparison function comparisonFunction
function <optional>
A function which compares two values which returns true if the values are considered the same. Returns:
int - The index of the value, -1 if not found -
static isList(list) → {boolean}
-
Checks if this is an Array or an After Effects collection type
Parameters:
Name Type Description list
Array | Collection The list to check Returns:
boolean - true if this is a Cllection or an Array -
static removeDuplicates(arr, comparisonFunctionopt) → {Array}
-
Removes all duplicated values from the Array, and returns them
Parameters:
Name Type Attributes Description arr
Array The array comparisonFunction
function <optional>
A function which compares two values which returns true if the values are considered the same. Returns:
Array - The duplicated (and removed) values