May 2011
Intermediate to advanced
1093 pages
40h 54m
English
Content preview from JavaScript: The Definitive Guide, 6th EditionBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
Start your free trial


Name
Object.preventExtensions() — don’t allow new properties on an object
Availability
ECMAScript 5
Synopsis
Object.preventExtensions(o)
Arguments
oThe object that is to have its extensible attribute set
Returns
The argument object o.
Description
Object.preventExtensions()
sets the extensible attribute of
o to false so that no new properties can
be added to it. This is a permanent change: once an object has been
made non-extensible, it cannot be make extensible again.
Note that Object.preventExtensions() does not affect
the prototype chain, and a nonextensible object can still gain new
inherited properties.
Note that this is not a method to be invoked on an object: it is a global function and you must pass an object to it.