15.2.3.9 Object.freeze(O)

2010-07-04

object Object.freeze(O:object) throws TypeError

This is basically the same as Object.seal except the [[Writable]] attribute of all properties are also set to false. This makes the object O fairly immutable.

Code: (Meta Ecma)
Object.freeze = function(O){
if (Type(O) != 'Object') throw TypeError;
for (P in O) {
var desc = O.[[GetOwnProperty]](P);
if (IsDataDescriptor(desc) && desc.[[Writable]]) desc.[[Writable]] = false;
if (desc.[[Configurable]]) desc.[[Configurable]] = false;
O.[[DefineOwnProperty]](P, desc, true);
}
return O;
}