LearnFrenzy
Sign in Take a free test

Destructuring · Exercise 1 of 4

Destructuring Destructuring MCQ

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

Fifteen multiple-choice questions on JavaScript destructuring: array and object patterns, skipping, defaults, renaming, rest, nested patterns, parameters, assignment syntax, iterables and errors. Pick an option to check your answer instantly.

Question 11 Hard

After const { address: { city } } = user;, which variables exist?

A address and city
B Only city
C Only address
D user, address and city
Question page & discussion
Question 12 Medium

Why is function init({ debug = false } = {}) written with = {}?

A To make debug read-only
B So init() can be called with no argument without trying to destructure undefined
C To copy the argument
D It is required syntax for every destructured parameter
Question page & discussion
Question 13 Medium

Which value can be destructured with an array pattern?

A A plain object { a: 1 }
B null
C A number
D A Set
Question page & discussion
Question 14 Easy

Which line swaps the values of a and b?

A [a, b] = [b, a];
B { a, b } = { b, a };
C a, b = b, a;
D [a, b] = [a, b];
Question page & discussion
Question 15 Medium

What does const [x, y] = { x: 1, y: 2 }; do?

A Throws a TypeError – the object is not iterable
B x = 1, y = 2
C x and y are undefined
D A SyntaxError
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