Question 12
Back to Exercise
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 Correct
- C To copy the argument
- D It is required syntax for every destructured parameter
Correct Answer: Option B
Without it, init() would destructure undefined and throw a TypeError. With it, the empty object is destructured and debug defaults to false.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!