understand the object

One: Understand the properties of objects

Property Types: Data Properties and Accessor Properties

1 Data attributes: A data attribute has four properties that describe its behavior

  1.1 Configurable: Indicates whether the attribute can be redefined by deleting the attribute through delete, whether the characteristics of the attribute can be modified, or whether the attribute can be modified as an accessor attribute

  1.2 Enumerable: Indicates whether the property can be returned through the for-in loop,

  1.3 Writable: Ability to modify the value of a property

  1.4 Value: Contains the value of this attribute. When reading the value of the attribute, read it here, write the value of the attribute, and save the new value in this place

To modify the default properties of the property: Object.defineProperty(), this method receives three parameters, the object where the property is located, the name of the property and the properties of the property (descriptor object)

Note 1: Once the attribute Configurable is defined as false, it cannot be changed back to configurable

 

2 Accessor properties: Accessor properties do not contain data values, they contain a pair of getter and setter functions, and the accessor has four properties

  2.1 Configurable

  2.2 Enumerable

  2.3 The function that Get calls when reading properties

  2.4 Functions that Set calls when writing properties

Accessor properties cannot be defined directly, they must be defined using Object.defineProperty()

3 Read the properties of the property Object.getOwnPropertyDescriptor(), this method receives two parameters, the object where the property is located, the name of the property, and the return value is an object

Two: Understanding Two-Way Binding

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325648072&siteId=291194637