0
0
Javascriptprogramming~5 mins

Common array operations in Javascript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the push() method do in an array?
It adds one or more elements to the end of an array and returns the new length of the array.
Click to reveal answer
beginner
How do you remove the first element from an array?
Use the shift() method. It removes the first element and returns it, shifting all other elements down by one index.
Click to reveal answer
intermediate
What is the difference between map() and forEach()?
map() creates a new array by applying a function to each element, while forEach() simply runs a function on each element without returning a new array.
Click to reveal answer
beginner
How can you find the index of a specific element in an array?
Use the indexOf() method. It returns the first index at which the element can be found, or -1 if it is not present.
Click to reveal answer
intermediate
What does the filter() method do?
It creates a new array with all elements that pass a test implemented by a provided function.
Click to reveal answer
Which method adds elements to the end of an array?
Apop()
Bunshift()
Cshift()
Dpush()
What does the pop() method do?
ARemoves the first element
BRemoves the last element
CAdds an element at the start
DAdds an element at the end
Which method creates a new array by applying a function to each element?
Amap()
Breduce()
Cfilter()
DforEach()
How do you find the position of an element in an array?
Afilter()
Bfind()
CindexOf()
Dslice()
Which method returns a new array with elements that pass a test?
Afilter()
Bmap()
Creduce()
DforEach()
Explain how to add and remove elements from the start and end of an array in JavaScript.
Think about methods that work at the beginning and end of the array.
You got /6 concepts.
    Describe the difference between map(), forEach(), and filter() methods.
    Focus on what each method returns and how they process array elements.
    You got /4 concepts.