Array
Basics
.length
.push(e)
.pop()
.shift()
- popleft returning first ele.unshift(e)
- pushes to array returning length.indexOf(e)
- return index of ele or -1.includes(e)
- return true/false.findIndex(y => y === 1)
- returns the first index which cause ft to return true.sort()
- Takes ft(a,b) =>
< 0 —
a
b4b
> 0 —
b
b4a
= 0 —
a
andb
unchanged
.reverse()
- return new???
Functional Stuff
.map(ft/1)
- return new array with ft applied to eachflatMap(ft/1)
- map followed by a depth 1flat()
, allows modification of number of elements.reduce(ft(acc, e), initialValue?)
- return single ele...some(ft/1)
- true if one ele satisfies ft given.filter(ft/1)
- return new array with elements where ft true
Can do async fts in map and then wrap it in a promise.all
Advanced
Subarr
.slice
for subarrs (start, end not included)
.splice([start index], [number beyond start], [item to insert opt])
for removing&saving section
.concat
combine two arrays
copy
For each
Executes a callback ft for each ele, returns undefined
Beware async stuff
array.forEach(callback[, thisArg])
Queue (works on array)
.push(e)
.pop()
.shift(e)
=> pop from beginning.unshift()
=> add to beginning
Is Array
Last updated