![]() |
VOOZH | about |
JavaScript handler.preventExtensions() method in JavaScript is a trap for Object.preventExtensions() method. New properties cannot be added to an object when extensions are disabled. It returns a boolean value.
Syntax:
const p = new Proxy(target, {
preventExtensions: function(target) {
}
});
Parameters: This method accepts a single parameter target that holds the target object.
Return value: This method returns a boolean value.
Below examples illustrate the handler.preventExtensions() method in JavaScript:
Example 1: In this example, we will see the use of the handler.preventExtensions() method in JavaScript.
Output:
true [object Object] false true
Example 2: In this example, we will see the use of the handler.preventExtensions() method in JavaScript.
Output:
preventExtensions() [object Object] [object Object] false false
Supported Browsers: The browsers supported by handler.preventExtensions() method are listed below:
We have a complete list of Javascript Proxy/handler methods, to check those go through the Javascript Proxy/handler Reference article.