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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *