1. Attributes of PropertiesA property consists of a name and 4 attributes. 4 Properties: Value, writable, enumerable, configurable
2. Three properties of an object
One: Prototype propertiesto detect whether an object is a prototype of another object, use the isPrototypeOf () methodsuch as:
var P={x=1}; // defining a prototype object var o=object.create (p); // Use this prototype object to create an object p.isprototypeof (o) //True:o inherits from Pobject.isprototypeof (p) // True:p inherited from Object.prototype
two: Class propertiesDetermine Class Property function: Classof ()
function classof (o) { if(o===null) { return ' null '; } if (o===undefined) { return "undefined"; } return Object.prototype.toString.call (o). Slice (8,-1);}
Run:
Classof (null) //"null"classof (1) //"number"classof ("") //"String"classof (new F ()) // "Object"classof (windoe) //"window" (This is the client host object)
Three: scalabilitythe extensibility of the object indicates whether a new property can be added to the object. all built-in objects and custom objects in ECMASCRIPT5 are extensible. The purpose of extensibility is to "lock" the object to avoid outside interference. use object.esextensible () to determine whether an object is extensible. use object.preventextensible () to convert the object to non-extensible. Once an object is converted to non-extensible, it cannot be converted to extensible.
Four: Serializing Objectsserialization refers to converting the state of an object to a string, or to restoring a string to an object. ECMASCRIPT5 provides built-in functions json.stringify () and json.parse () such as:
o={ x:1, y:{ z:[false,null, ""] }}s=json.stringify (o) // ' {"x": 1, "Y": {"Z": [False,null, ""]} 'P=json.parse (s) // p is a deep copy of O
JavaScript authoritative design--javascript object (brief study note eight)