JavaScript: Reflect.preventExtensions

By Xah Lee. Date: . Last updated: .

New in JS2015.

Reflect.preventExtensions( obj )
Sets obj's extensible attribute to false. Return true if success, else false. If obj is not object, throw a TypeError exception.
[See also: Object.preventExtensions]

[see Prevent Adding Property]

const u = {};
console.log( Reflect.isExtensible ( u ) ); // true
Reflect.preventExtensions ( u );
console.log( Reflect.isExtensible ( u ) ); // false

Reflect.preventExtensions vs Object.preventExtensions?

What's the difference?

Object.preventExtensions( arg) does not complain if arg is not a object.

JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

Reflect