Array Class
Methods
clear
-
[deepClear=false]
Clears an Array, removing all its elements;
Parameters:
-
[deepClear=false]
Boolean optionalIf it is required for all the array elements to be cleared, this paramenter should be true; can be omitted otherwise;
If deep clearance is required, thie method will try to call the clear method for each and every element of this array (Object class has already been extended with a clear method).
Returns:
map
-
f
-
[contest=window]
Maps a function on every element of the array, creting a new array populated with the results of these calls.
Parameters:
-
f
FunctionThe function to map on the array;
-
[contest=window]
Object optionalThe new this pointer for the function to map, if needed;
Returns:
max
-
[extract_element_key]
Return the maximum element of an array.
Parameters:
-
[extract_element_key]
Object optionalA function that, given any element of the array, will produce a numeric value used for ranking the element itself (its sorting key)
Returns:
min
-
[extract_element_key]
Return the minimum element of an array.
Parameters:
-
[extract_element_key]
Object optionalA function that, given any element of the array, will produce a numeric value used for ranking the element itself (its sorting key)
Returns:
shallowCopy
-
[n]
Creates a new array (shallow) copying the elements of the current one
Parameters:
-
[n]
Object optionalIf defined, the max number of elements to copy from the current array
Returns:
sum
()
Number | String
Sums the elements of an array.
Returns:
- If all the elements in the array are numbers, then returs their arithmetic sum
- If any element of the array isn't a number, returns a string obtained by concatenating the partial arithmetic sum until that element, and the concatenation of the string conversion of every other element in the array.