Question 12
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
const dict = Object.create(null);
dict.apple = 1;
console.log("toString" in dict, typeof dict.toString, Object.keys(dict));
- A true function [ 'apple' ]
- B true function [ 'apple', 'toString' ]
- C false undefined [ 'apple' ] Correct
- D TypeError
Correct Answer: Option C
Object.create(null) has no prototype chain, so nothing is inherited – not even toString.
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!