Arrays Flashcards
Code an array iteration
let bestColors = [‘green’, ‘blue’, ‘yellow’]
bestColors.forEach( x => console.log(x))
Each content item inside an array is called
An element
Each element in an array has a numbered position known as
It’s index
How many ways are there to declare array and what are they?
Two
Literal notation:
let newArr = []
Constructor
True or False: Arrays in JavaScript are zero-indexed
True
What are arrays?
A data structure to store ordered collections (collections of elements)
What does pop() do?
Removes the last item of the array
What does shift() do?
The shift() method removes the first element from an array and returns that removed element. This method changes the length of the array
What does unshift() do?
The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array
What does zero-indexed mean?
The positions start counting from 0 rather than 1
What is an array literal?
Creates an array by wrapping items in square brackets []
What is the difference between .forEach and .map()?
.map() returns a new array
What is an array underneath the hood?
An object