# Arrays
There's nothing to say, just Array Methods 😃
- view array methods
# The Basic
concat()
every()
filter()
forEach()
indexOf()
join()
lastIndexOf()
map()
pop()
push()
reduce()
reduceRight()
reverse()
shift()
slice()
some()
toSource()
sort()
splice()
toString()
unshift()
# forEach
- note: Array.forEach
doesn't
wait forasync
calls !! - pls use
for...in
orfor
# find
arr.find
- get the
first
element back that causes the given callback function to return true
# findIndex
arr.findIndex
findIndex
returns theindex
of that element
# entries
arr.entries
- Entries will return an array of arrays, where each child array is an array of
[index, value]
var numbers = [1, 2, 3];
var val = numbers.entries();
console.log(val.next().value); // [0,1]
console.log(val.next().value); // [1.2]
console.log([...val]); //[[0,1],[1,2],[2,3]]
# from
arr.from
convert
two kinds of values to Arrays :- Array-like values
- Iterable values like Set and Map
for (let i of Array.from('hello')) {
console.log(i)
}
res:
h
e
l
l
o
# keys
arr.keys()
- returns the array
indexes