JS Array Methods Flashcards
1
Q
arr.concat()
A
combines arrays since JS cannot do this using +
returns a new array containing all the elements from the old arrays
can take multiple arguments to combine multiple arrays
example:
[1, 2].concat([3, 4], [5, 6])
[1, 2, 3, 4, 5, 6]
2
Q
arr.includes()
A
can check for whether an array includes an element
returns boolean
example:
[‘a’, ‘b’].includes(‘c’)
false
3
Q
arr.fill()
A
fills an array with a given value
existing values will be overwritten by the given value