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
setting / accessing via anything other than nonnegative integers๏ผ
will not set / retrieve an array element
If an array literal contains multiple commas in a row, with no value between, the array is sparse.
other topics
๐ array-like - object that has indexes and length.
๐ฐ accessing elements
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)
find & search elements
find - ๅๅณ็ฌฌไธๅ็ฌฆๅๆขไปถ็ๅ
็ด ใๅฆๅๅๅณ undefined
ใ
findIndex - returns index of first matching element, -1
otherwise.
includes - ๅคๆท้ฃๅๆฏๅฆๅ
ๅซ็นๅฎๅ
็ด ใ
some - ๆธฌ่ฉฆ้ฃๅไธญๆฏๅฆๆ็ฌฆๅๆขไปถ็ๅ
็ด ใ
every - returns true if every element satisfies the condition.
( ๐ง to be removed ... )
How to get first N number of elements from an array