To construct a new array with uninitialized elements, use the constructor
of this class. To construct a new array with specified elements, as if
you used the array literal syntax in JavaScript, use the companion object's
apply method instead.
Note that Javascript === equality semantics apply. JsArray does not know
anything about Scala equals method or the case classes structural equality.
- Type parameters:
- A
Type of the elements of the array
- Constructor:
Creates a new array of length 0.
- Companion:
- object
Value members
Constructors
Create a new array with the given length
(filled with js.undefined irrespective of the type argument A!).
Create a new array with the given length
(filled with js.undefined irrespective of the type argument A!).
See companion object for more factories.
- Value parameters:
- arrayLength
Initial length of the array.
Concrete methods
Create a new array consisting of the elements in the this object on which it is called, followed in order by, for each argument, the elements of that argument
Create a new array consisting of the elements in the this object on which it is called, followed in order by, for each argument, the elements of that argument
Create a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function.
Create a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function.
Note: this implementation is faster than calling into JS native forEach.
Note: this implementation is faster than calling into JS native forEach.
Similar to the native two-argument version of forEach
Similar to the native two-argument version of forEach
Join all elements of an array into a string.
Join all elements of an array into a string.
separator Specifies a string to separate each element of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma.
Set the length of the array.
Set the length of the array.
If the new length is bigger than the old length, created slots are
filled with undefined (irrespective of the type argument A!).
If the new length is smaller than the old length, the array is shrunk.
- See also:
Create a new array populated with the results of calling a provided function on every element in the calling array.
Create a new array populated with the results of calling a provided function on every element in the calling array.
Remove the last element from an array and returns that element.
Remove the last element from an array and returns that element.
Returns js.undefined if array is empty.
Mutate an array by appending the given elements and returning the new length of the array.
Mutate an array by appending the given elements and returning the new length of the array.
- Value parameters:
- f
(accumulator, nextValue) => nextAccumulator On first call of
f,accumulatorisarray[0], andnextValueisarray[1]. If array only has one item, array[0] is returned without callingf. Note: throws exception if array is empty.
- Value parameters:
- f
(accumulator, nextValue) => nextAccumulator On first call of
f,accumulatorisinitial, andnextValueisarray[0]If array is empty or only has one item,initialis returned without callingf.
- Value parameters:
- f
(accumulator, nextValue, nextIndex) => nextAccumulator On first call of
f,accumulatorisarray[0], andnextValueisarray[1]. If array only has one item, array[0] is returned without callingf. Note: throws exception if array is empty.
- Value parameters:
- f
(accumulator, nextValue, nextIndex) => nextAccumulator On first call of
f,accumulatorisinitial, andnextValueisarray[0]If array is empty or only has one item,initialis returned without callingf.
Reverse an array in place. The first array element becomes the last and the last becomes the first.
Reverse an array in place. The first array element becomes the last and the last becomes the first.
Remove the first element from an array and return that element.
Remove the first element from an array and return that element.
Returns js.undefined if array is empty.
Sort the elements of an array in place and return the array. The default sort order is lexicographic (not numeric).
Sort the elements of an array in place and return the array. The default sort order is lexicographic (not numeric).
!! The sort is not stable in IE!
If compareFn is not supplied, elements are sorted by converting them to strings and comparing strings in lexicographic ("dictionary" or "telephone book," not numerical) order. For example, "80" comes before "9" in lexicographic order, but in a numeric sort 9 comes before 80.
- See also:
Remove and add new elements at a given index in the array.
Remove and add new elements at a given index in the array.
This method first removes deleteCount elements starting from the index
index, then inserts the new elements items at that index.
If index is negative, it is treated as that number of elements starting
from the end of the array.
- Value parameters:
- deleteCount
Number of elements to delete from index
- index
Index where to start changes
- items
Elements to insert at index
- Returns:
An array of the elements that were deleted
Add one or more elements to the beginning of the array and return the new length of the array.
Add one or more elements to the beginning of the array and return the new length of the array.