Home » JavaScript handler defineProperty() Method

JavaScript handler defineProperty() Method

by Online Tutorials Library

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.

  1. When we wanted to ensure cross-browser support of getters and setters.
  2. 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

Test it Now

Output:

[object Object]  

Example 2

Test it Now

Output:

in defineProperty  

Example 3

Test it Now

Output:

Learn Java Script Proxt Method  

Next TopicJavaScript handler

You may also like