To avoid iterating over prototype properties with for...in, you should use the _______ method.

  • Object.keys
  • hasOwnProperty
  • Object.prototype
  • Object.values
To avoid iterating over prototype properties with a for...in loop, you should use the Object.keys method. This method returns an array of an object's own enumerable property names, allowing you to iterate over only the object's properties without including those from its prototype chain.
Add your answer
Loading...

Leave a comment

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