JavaScript Reflect.preventExtensions() Method

The static Reflect.preventExtensions() method is used prevent future extensions to the object. This method is same as Object.preventExtensions() method.

Syntax:

Parameters:

Obj: It is the object on which to prevent extensions.

Return value:

This method returns true if the target was successfully set to prevent extensions. Otherwise, this method returns false.

Exceptions:

A TypeError, if the target is not an Object.

Browser Support:

Chrome49
Edge12
Firefox42
Opera36

Example 1

Output:

true
false

Example 2

Output:

true
true

Example 3

Output:

false
false




Latest Courses