Create two main forms of an object, create an object instance, and create objects literal
Object contains properties and methods
Data
, attributes have four attributes that describe the behavior of the property, and they are:
Whether the configurable (configurable) can be deleted or modified to be accessor properties
Whether the Enumerable (enumeration) can be for-in
Writeable (writable) ability to modify property values
Value (value) defaults to undefined, reading data from this location or saving the new value to this location
eg
var person = {} ';
Object.defineproperty (person, "name", {writeable:false,value: "fff"});//person.name becomes read-only.
However, it is important to note that the Configurable:false attribute in Object.defineproperty () is not configurable, and cannot be used except for the writeable, and cannot be passed: True to change back,
JavaScript Advanced Programming-the sixth chapter of object-oriented programming