Sixth Chapter Object
1. The method of an object is usually an inherited property . This prototype inheritance is the core feature of Js.
2. In addition to the name and value , each attribute has some value associated with it, called the attribute attribute -writable /enumerable/ configurable. the four attributes of the data attribute -- value, writable, enumerable, configurable, accessor four features -- read, write, enumerable, configurable.
3. In addition to the include attribute, each object also has three related object attributes ( three properties of the Object)-an extended tag for the class/object of the Object's prototype/object .
4. objects can be created by the Object Direct volume / keyword new and (ES5)object.create () function .
5. If the Object's direct amount is used in a loop inside a repeating function, it will create many new objects, and the property values of each object created may be Different.
6.Object.prototype is one of the few objects without a prototype , and it does not inherit any Attributes.
7. Theobject.create () function can create a new object without a prototype by passing in the parameter null, but objects created in this way do not inherit anything, not even the underlying method. If you want to create a normal empty object, you need to pass in Object.prototype.
8, the object query using square brackets and a string, looks like an array, this array is what we call an associative array , also known as hash/map/dictionary . JS objects are associative arrays .
9 . The object query uses square brackets when the string inside the square brackets is dynamic and can be changed at run Time. When Using. and identifiers, identifiers are static and must be written dead in the Program.
10. You cannot overwrite a read- only inherited property by its own Property.
11. Delete Simply disconnects the property from the host object and does not manipulate the properties in the Property. to ensure that the object is destroyed, iterate through the properties in the property, and then delete it. The delete operator can only delete its own property and cannot delete the inherited Property.
12. Detection Properties : This work can be done through the in operator ,hasownproperty () and propertyisenumerable () method , even through Property Queries are also available.
13. The In operator contains this property in the Object's own or inherited property to return True. The hasOwnProperty () method of an object is used to detect whether a given name is an Object's own property , and it returns false for inherited Properties. Use together to detect whether a property is an inherited Property.
14, propertyisenumerable () is an enhanced version of hasOwnProperty () and returns true only if it detects that it is a property of its own and can be enumerated .
15. Enumeration Properties :for/in loop , ES5 's object.keys () function (enumerable own property) and object.getownpropertynames () (returns all its own properties, not only enumerable).
16, the attribute value can be replaced by one or two methods, the two methods are getter and setter. Properties defined by getter and setter are called accessor properties .
17. You can get the property Descriptor (property Descriptor Object) for an object-specific property by calling Object.getownpropertydescriptor () . To set attributes for a property, or to have a new property with some attribute, you need to call Object.defineproperty (), pass in the object you want to modify, the name of the property you want to create or modify, and the property descriptor Object.
18. to detect whether an object is a prototype of another object or in a prototype chain, use the isprototypeof () method . Similar to the instanceof Operator.
19. to get the class of the object, you can call the Object's toString () method , and then extract the characters between the 8th and second-to -last positions of the String. Object.prototype.toString.call (o). Slice (8,-1);
20. ES5 provides built-in functions json.stringify () and Json.parse () to serialize and restore JS Objects.
21, the extensibility of the object:object.preventextensions () can not be added, but the existing may be deleted can be changed. object.seal () can not be added to delete, the existing may be changed. Object.freeze () Cannot add delete changes (accessor properties are not affected).
Js-authoritative Guide Study Notes 5