A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/Object/freeze below:

freeze ยท WebPlatform Docs

freeze Summary

Prevents the modification of existing property attributes and values, and prevents the addition of new properties.

Syntax
Object.freeze( object )
object
Required. The object on which to lock the attributes.
Return Value

The object that is passed to the function.

Examples

The following example illustrates the use of the Object.freeze function.


 var obj = { pasta: "spaghetti", length: 10 };

 
 Object.freeze(obj);

 
     obj.newProp = 50;
     document.write(obj.newProp);
     document.write("<br/>");

 
 delete obj.length;
 document.write(obj.length);
 document.write("<br/>");

 
 obj.pasta = "linguini";
 document.write(obj.pasta);

 
 
 
 
Remarks

The Object.freeze function does the following:

For more information about how to set property attributes, see Object.defineProperty Function. To obtain the attributes of a property, you can use the Object.getOwnPropertyDescriptor Function.

The following related functions prevent the modification of object attributes.

Function Object is made non-extensible configurable is set to false for each property writable is set to false for each property Object.preventExtensions Yes No No Object.seal Yes Yes No Object.freeze Yes Yes Yes

The following functions return true if all of the conditions marked in the following table are true.

Exceptions

If the object argument is not an object, a TypeError exception is thrown.

See also Other articles Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4