1. Overview of objects
1. Common usage of objects:
Create, set, Query, delete, test, enumerate
2. Attribute properties of the object:
Writable, enumerable, configurable
3. Object properties for each object:
Prototypes, Class of objects, extensibility of objects
4. Object and attribute classification:
Built-in objects, host objects, custom objects, free attributes, inherited properties
2. Create objects
1. Direct volume of objects
2. Create an object from new
3. Prototypes
4, Object.create ()
First parameter: The prototype of this object
Second parameter: Optional, further description of the properties of the object
var // O1 inherits Properties X and Y. var o2 = Object.create (null// O2 inherits no props or methods. var // O3 is a like {} or New Object ().
generic inherit () function, compatible version (but not completely replace create if the second parameter cannot be accepted)
functioninherit (p) {if(p = =NULL)ThrowTypeError ();//p must be a Non-null object if(object.create)//If object.create () is defined ... returnObject.create (P);//Then just use it. vart =typeofP//Otherwise do some more type checking if(t!== "Object" && t!== "function")ThrowTypeError (); functionF () {};//Define a dummy constructor function.F.prototype = p;//Set its prototype property to P. return Newf ();//Use f () to create an "heir" of P.}
3. Query and settings for attributes
1. Object as an associative array
JavaScript objects are associative arrays, the difference between point access and parenthesis access
2. Inheritance
3. Property Access Error
var len = Book && book.subtitle && book.subtitle.length;
The purpose of this code: to avoid property access errors
The following scenario causes the object o to set the property p to fail:
1, the attribute p in O is read-only
2, o the attribute p is inherited, and is read-only: cannot overwrite the inherited property of a read-only property through its own property
3.
JavaScript authoritative Guide Notes (6th Chapter object)