(Object)
an ordered collection of values.
each element has a numeric position in the array, known as its index.
JavaScript arrays are untyped:
an array element may be of any type.
different elements of the same array may be of different types.
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
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