JS Learning Notes (i)

Source: Internet
Author: User

JS in layman's one. Object created by New Foo ():  1. The object's prototype will point to the prototype property of the constructor of Foo, and the advantage is that if the object's property is accessed, if it does not exist, it will continue to look up the value on the prototype property of Foo based on the prototype chain; 2. When you use in to determine whether the property belongs to the object, it is true, meaning that the property is on the prototype chain of the object; 3. When assigning a value to the property of the object, the property is modified if it exists on the prototype chain, and if it does not exist, only one property is added to the object and the value is assigned; 4. Use hasOwnProperty to determine whether the property exists on the object or on the prototype chain; Delete can only delete properties on the object, not the properties on the prototype chain; 5. Create an object with Var obj=object.create ({x:1}), and the object's prototype points to the parameter , which is obj.x=1, while the prototype of the object created by literal is object.prototype two. Action Properties 1.for in traversing a property, it is possible to traverse the properties of the prototype chain, and is an unordered 2.delete delete attribute, the returned ture indicates that the object has no such property, rather than delete the meaning of success; 3.var descriptor = Object.getownpropertydescriptor (Object, ' prototype ') property descriptor 4. Implicitly created global variables can also be deleted with delete,   for example  i=1,delete i; An object created with Var in eval () can also delete 5.propertyIsEnumerable () whether the property can be traversed by 6. Custom Attribute enumerable Object.defineproperty (cat, ' price ', { ENUMERABLE:FALSE,VALUE:100}), when a new or literal object is created or assigned to a property, the default is writable and enumerable (the label is all true), with define, the default is all False7. in var obj = Object.defineproperty (foo.prototype, ' Z ', {get:function () {return {value:1}}}) assigns a value to a property on a prototype chain (with a Get method to assign a value), It is not successful to assign a value to the obj.z, nor does it create this property on obj, and it is only possible to assign a value through obj.DefineProperty8.object.keys () is also a traversal9. Property Tags: configurable=true, you can use DefineProperty to modify the value or other property labels, and delete the property using Delete, if wirtable=true, you can directly use OBJ.Z to assign the value directly 10. Object tag: proto,class,extension--isextensible () or preventextensions (), seal () is further than Preventextensions (), It changes the configurable label of all existing attributes to false, while Freeze () is the most bullish, and all property labels are set to False 11. Serialization of Objects: Json.stringfy ()

Json.parse () parsing, but requires double quotes for all attributes
ValueOf ()

JS Learning Notes (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.