📘Array
🚧 under construction
JS ⟩ value ⟩ object⟩ built-in ⟩ Array
array
is iterable
is not associated array.
inherits methods from Array.prototype, most of these methods are generic, they work correctly for any "array-like" object.
⚖️ array object properties vs. array elements
thery are separate❗
array's traversal and mutation operations cannot be applied to these named properties.
setting / accessing via anything other than nonnegative integers:
will not set / retrieve an array element
will set / access one of the array's object properties.
deleting an array element leaves a “hole” in the array and does not change the array’s length❗ (sparse array)
🔰 extending Array
other topics
🍄 array-like - object that has indexes and length.
🍄 sparse array - array that has "holes" in it.
push() - append element.
pop() - remove and return last element.
unshift() - prepend element.
shift() - remove and return first element.
combine elements
join - 連接所有元素、合併成一個字串。
reduce((result, element, index, array) => {...}) -
reduceRight - reduce array from highest index to lowest. (from right to left)
Array is iterable.
bracket notation [] is used to access element.
JavaScript: The Definitive Guide > Ch. 7 Arrays
( 🚧 to be removed ... )
matrix methods (instance):
mat.transpose() - see matrix in "columns"
mat.maxElementInEachColumn() - for number matrices only.
How to get first N number of elements from an array
Last updated
Was this helpful?