In which scenario might you prefer to use Object.create(null) over {} to create an empty object?
- When you need an empty object with no prototype chain (no inherited properties or methods)
- When you need an empty object with default prototype properties
- When you need an object with prototype properties
- When you need an object with getter and setter methods
Object.create(null) is used when you want an empty object with no prototype chain. This is useful when you want to create a clean slate object without inheriting any properties or methods from the Object prototype.
Loading...
Related Quiz
- The pop() method removes the last element from an array and returns _______.
- What does the async keyword do in front of a function in JavaScript?
- Which method is used to select an element by its ID in JavaScript?
- The _______ pattern is used to create an instance of an object with some default values.
- While working with React, you notice a function defined using the function keyword is not updating the component state as it should. You suspect it's related to the "this" keyword. What might be the problem?