The Reflect.preventExtensions(object) method

The Reflect.preventExtensions() is used to mark an object as non-extensible. It returns a Boolean, indicating whether the operation was successful or not.

It's the same as the Object.preventExtensions() method:

var obj = { name: "Eden" };console.log(Reflect.isExtensible(obj)); //Output "true" console.log(Reflect.preventExtensions(obj)); //Output "true" console.log(Reflect.isExtensible(obj)); //Output "false"

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.