Rules for using get trap

These rules shouldn't be violated when using the get trap:

  • The value returned for a property must be the same as the value of the target object property if the target object property is a non-writable, non-configurable data property.
  • The value returned for a property must be undefined if the target object property is a non-configurable accessor property that has undefined as its [[Get]] attribute.

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.