LearnFrenzy
Sign in Take a free test

Arrays · Exercise 1 of 4

Arrays JavaScript Arrays MCQ

  • 15 questions
  • Page 2 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Fifteen multiple-choice questions on JavaScript arrays: creating arrays, push and pop return values, slice vs splice, sort, length and holes, at(), indexOf vs includes, copying, fill and the ES2023 non-mutating methods. Pick an option to check your answer instantly.

Question 11 Hard

What is the problem with const rows = new Array(3).fill([]);?

A fill cannot be used with arrays
B It creates three holes
C All three slots hold the same array, so pushing into one row changes every row
D It throws a TypeError
Question page & discussion
Question 12 Medium

Which method changes the array it is called on?

A slice()
B concat()
C reverse()
D toSorted()
Question page & discussion
Question 13 Hard

On an array with a million elements, why is unshift(x) usually much slower than push(x)?

A unshift sorts the array first
B push is cached by the engine
C unshift has to move every existing element one index up; push only writes at the end
D There is no difference
Question page & discussion
Question 14 Medium

What is the difference between arr.sort() and arr.toSorted()?

A toSorted() sorts in descending order
B They are identical
C toSorted() works only on strings
D sort() sorts arr in place; toSorted() returns a sorted copy and leaves arr unchanged
Question page & discussion
Question 15 Medium

Which of these can Array.from turn into a real array?

A A string, a Set, a Map, a NodeList or an object like { length: 3 }
B Only other arrays
C Only numbers
D Only objects created with new
Question page & discussion
Up next · Exercise 2Predict the Output20 questions

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links