Question 12
Back to Exercise
Why would you create a dictionary with Object.create(null) instead of {}?
- A It is frozen automatically
- B It is faster to stringify
- C It has no prototype, so keys such as "toString" or "constructor" do not collide with inherited properties Correct
- D It allows object keys
Correct Answer: Option C
A {} object inherits from Object.prototype, so "constructor" in dict is true even when you never added it. A null-prototype object starts truly empty.
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!