74
JavaScript handler.defineProperty() Method
The handler.defineProperty() method can define the new properties. It can also modify the existing properties directly on an object. It is trap for Object.defineProper(). This method can be used in two situations.
- When we wanted to ensure cross-browser support of getters and setters.
- Whenever we want to define a custom property accessor.
Syntax
Parameters
Target: The target object.
Property: Retrieved property description.
Descriptor: The property being defined or modified.
Return value
This method returns a Boolean
Browser Support
Chrome | 49 |
Edge | 12 |
Firefox | 18 |
Opera | 36 |
Example 1
Output:
[object Object]
Example 2
Output:
in defineProperty
Example 3
Output:
Learn Java Script Proxt Method
Next TopicJavaScript handler