Js deep learning notes (1)
Js is a simple introduction. new Foo (): 1. the prototype of the object directs to the prototype attribute of the Foo constructor. The advantage is that if the object does not exist when accessing the property of the object, the prototype attribute value of Foo will be searched based on the prototype chain; 2. true indicates that the property belongs to the prototype chain of the object. when assigning a value to an object property, the system first checks whether the property exists in the prototype chain and then modifies it. If the property does not exist, it adds only one attribute to the object and assigns a value. 4. hasOwnProperty is used to determine whether the property exists on the object or the prototype chain. delete can only delete the property on the object without affecting the property on the prototype chain. use var obj = object. create ({x: 1}) creates an object. The prototype of this object points to the parameter, that is, obj. x = 1; the prototype of the object created using the literal is object. prototype 2. when operating on Attribute 1.for in, it is possible to traverse the attribute on the prototype chain, and it is unordered 2. when the delete operation deletes an attribute, the returned true indicates that the Object has no such attribute, instead of deleting it successfully. 3.var descriptor = Object. getOwnPropertyDescriptor (Object, 'prototype') attribute descriptor 4. you can also use delete to delete the globally created variables implicitly, such as I = 1 and delete I. You can also delete the objects created by using var in eval. propertyIsEnumerable () can this attribute be traversed? 6. user-Defined attributes can enumerate objects. defineProperty (cat, 'price', {enumerable: false, value: 100}), when an object is created using new or literal or assigned a value to an attribute, the default value is writable and enumerative (all labels are true). If define is used, the default value is false 7. in var obj = Object. defineProperty (Foo. prototype, 'z', {get: function () {return {value: 1 }}) assign values to properties on a prototype chain (assign values using the get method ), and then give the obj. z assignment is unsuccessful. This attribute will not be created on obj. To assign a value, you can only use obj. defineProperty 8. object. keys () is also traversal 9. attribute label: Optional able = true, you can use defineProperty to modify the value or other attribute labels, and you can use delete to delete the attribute. If wirtable = true, You can directly use obj. z to assign 10 values directly. OBJECT Tag: proto, class, extension -- isExtensible () or preventExtensions (), seal () is more advanced than preventExtensions (). It changes the retriable tag of all existing attributes to false; freeze () is the best, and all attribute labels are set to false 11. object serialization: JSON. stringfy ()
JSON. parse () Resolution, but all attributes must be enclosed in double quotation marks
12. valueOf ()