Use array to store multiple elements
Construct an array using [] syntax
size: Return the size of the array.
As of 1.4.3+. You can use most of lodash function on an array: https://lodash.com/docs/4.17.15
Available functions:
number push(element: any)
Adds one element to the end of an array and returns the new length of the array.
| Parameters | |
| element | The element to add |
| Return | |
| number | The new length of the array |
any pop()
Removes the last element from an array and returns that element. This method changes the length of the array.
| Return | |
| any | The last element in the array |
number unshift(element: any)
Adds one element to the beginning of an array and returns the new length of the array.
| Parameters | |
| element | The element to add |
| Return | |
| number | The new length of the array |
any shift()
Removes the first element from an array and returns that element. This method changes the length of the array.
| Return | |
| any | The first element in the array |
number insertAt(index: number, element: any)
Inserts one element at the index and returns the new length of the array.
| Parameters | |
| index | The index to insert. index >= 0 and index < size |
| element | The element to insert |
| Return | |
| number | The new length of the array |
number insertRange(index: number, elements: array)
Inserts elements at the index and returns the new length of the array.
| Parameters | |
| index | The index to insert. index >= 0 and index < size |
| elements | The array of elements to insert |
| Return | |
| number | The new length of the array |
any removeAt(index: number)
Removes one element at the index and returns the new length of the array.
| Parameters | |
| index | The index of the element to remove. index >= 0 and index < size |
| Return | |
| number | The new length of the array |
number removeRange(startIndex: number, endIndex: number)
Removes elements from startIndex to endIndex and returns the new length of the array.
| Parameters | |
| startIndex | The start index. index >= 0 and index < size |
| endIndex | The end index. index >= 0 and index < size |
| Return | |
| number | The new length of the array |
array slice(startIndex: number, endIndex: number)
Returns a shallow copy of a portion of an array into a new array selected from startIndex to endIndex (end not included). The original array will not be modified.
| Parameters | |
| startIndex | The start index. index >= 0 and index < size |
| endIndex | The end index. index >= 0 and index <= size |
| Return | |
| array | The new array |
array concat(elements: array)
Merges two arrays. This method does not change the existing arrays, but instead returns a new array.
| Parameters | |
| elements | The array to merge |
| Return | |
| array | The new merged array |
number clear()
Removes all elements in the array. Return 0
| Return | |
| number | The new size which is 0 |
array clone()
Shallow copy all the elements of the array
| Return | |
| array | The new array |
© 2025 - Macrorify by KoK-CODE