JS study notes (d) objects

In addition to containing the object properties, but also has three associated object properties:

Prototype (prototype) 1. object: point to another object, the present object attributes inherited from its prototype object.

Class (class) 2. object: identifying an object type is a string.

3. Extensible Markup object (extensible flag): Indicates whether to add a new attribute to the object.

 

 

The object is equal to the operation to copy the address of the object to the other, belonging to shallow copy

 

Cloning objects:

. 1 Function.prototype.clone = function (O) { // subject cloning method 
2   function the Temp () {}; // new empty constructor 
. 3 Temp.prototype = O; // the parameters assigned to the object constructor function of the prototype objects 
. 4  return  new new the Temp (); // returns the object instantiated after 
5 }

 

 

Object Properties features:

1. Writable (writable attribute) can set whether the value of the property

2. enumerable (enumerable attribute) whether by for / in loop returns the attribute

3. Configurable (configurable attribute) indicate whether you can delete or modify the attribute

 

Delete Attribute: delete operator to delete the object properties, delete object attribute, the attribute value is not set to undefined, but completely removed from the subject property.

 

Inside this object contains a keyword, it will always refer to the object calling the method.

 

Configuration Features:

Object.seal (object): attempting to modify the characteristics of an existing property, and prevents the addition of new properties. But property is not protected.

Object.freeze (object): attempting to modify an existing property values ​​and characteristic, and prevent add new properties.

Object.preventExtensions (object): prevents the addition of new properties.

Guess you like

Origin www.cnblogs.com/minnong/p/11289844.html