JS Authoritative Guide reading notes (ii)

Source: Internet
Author: User
Tags variable scope hasownproperty

fourth chapter expressions and operators1new Call constructor procedureA creates a new empty object B sets the _proto_ of the empty object to the constructor prototype prototype C calls the constructor with this new object as the value of this. If the constructor does not return an object value, the new Object 2 Lvalue: Represents the object stored in computer memory. 3 The result of a divisor of 0 is a positive infinity or a negative infinity,The result of 0/0 is Nan. The 4-bit operators convert Nan, infinity, and-infinity to 0. 5The in operator expects that its left operand is a string or can be converted to a string, the right operand is an object.    6 a op = b and a = a op b, the two are unequal only if a contains expressions with side-effects, such as function calls and assignment operations. Adata[i++]*= 2 and data[i++]=data[i++]*2 are not equivalent.7 about eval () Most importantly, it uses its variable scope environment. That is, it looks for the value of the variable and the operation that defines the new variable and function is exactly the same as the code in the local scope. 8 Eval has the ability to change local variables, which is a big problem for the JS optimizer. In non-strict mode, var Geval = eval is allowed, so that the Geval (params) is invoked indirectly, the global object is used as the context scope, and the local variables and functions are not read and written. 9 typeof object and original value the operand of the delete is an lvalue, otherwise no action is taken to return true to the fifth statement 1;(empty statement), and the JS interpreter does not perform any action when the empty statement is executed. 2 var and function are declaration statements that declare or define a variable or function. 3the difference between a function declaration and a function definitionA function declaration: the name of a function can be taken inside the function and within the parent scope (essentially declaring a variable and assigning the function object to the variable);b function Definition: The function's name can only be taken inside the function. The 4 return and break statements are used to terminate the switch statement. 5 switch executes for each case matching operationIdentity。 6 break and continue are the only uses in JSStatement LabelThe statement. 7 try/catch/finally statement is the exception handling mechanism of JS. The 8 with statement is used to temporarily extend the scope chain, with () {}. Sixth. Object 1 The property name can be any string that contains an empty string, but there cannot be two properties of the same name in the object. 2 Property attribute a value (value) b writable (writable), which indicates whether the value of the property can be set to C enumerable (enumerable), indicating whether the property can be returned by a for/in loop DConfigurable (configurable), indicating whether the property can be deleted or modified3 Memory Property attributes read (get) write (set) enumerable and configurable 4 object properties a prototype of object A (prototype) bThe class of the object is a string that identifies the object typeThe extension tag (extensible) of the C object indicates whether a new property can be added to the object 5 can be obtained through the object direct amount, the keyword new, and theobject.create ()function to create an object. 6 Object.create can create a new object without a prototype by passing in a parameter null, and objects created in this way do not inherit anything, not even the underlying method. The 7 property assignment operation first checks the prototype chain to determinewhether the assignment operation is allowed。 If the object o inherits a read-only attribute x, then the assignment is not allowed. If an attribute assignment operation is allowed, it always creates a property on the original object or assigns a value to an existing property. Setting properties is independent of inheritance only when querying properties with respect to inheritance. With one exception,if o inherits from Attribute X, and this property is a accessor property with a setter method, then the setter method is called instead of creating an attribute X for O. It is important to note that the setter method is called by the object o , not the prototype object .。 8Detection Properties: 9 propertyisenumerable is an enhanced version of hasOwnProperty through the in operator, the hasOwnProperty (), and the propertyIsEnumerable () method. It returns true only if its own property is detected and the enumerable of this property is true. 10 Enumeration Properties: A can be for/in by looping (enumerable own and inherited properties) b Object.keys () (enumerable own property) Cobject.getownpropertynames ()(All owned properties) 11 properties defined by getter and setter are called accessor properties and can also be inherited. 12 A property descriptor for an object-specific property can be obtained by calling Object.getownpropertydescriptor (). 13 by callingObject.defineproperty ()You can set properties for a property. 14 Writable controls the modification of the value attribute. 15 configurable controls modifications to other features, including whether attributes can be deleted. Specific rules: A If the attributes (data properties & memory properties) are not configurable, you cannot modify the configuration and the enumerable; b if the memory property is not configurable, you cannot modify its getter and setter methods, and you cannot convert it to a data property; c If the data belongs to is not configurable, it cannot be converted to a memory property; dIf the Data property is not configurable, it cannot be modified from false to true, but can be modified from true to Falsee If the Data property is not configurable and is not writable, its value cannot be modified. However, the value of a configurable but non-writable property can beManualModified (actually marking it as writable, modifying the value, and then converting it to non-writable) F If the object is not extensible, you cannot add a new property to it. 16 bycall isprototypeof ()Detects whether an object is a prototype of another object. 17 byobjects created with built-in constructors (Array date, and so on) have class properties。 18Object.prototype.toString.call (o). Slice (8,-1) = = Class Property19 Object Extensibility A object.isextensible () whether extensible B Object.preventextensions () is converted to non-extensible C Object.seal () in addition to being converted to non-extensible, all of the object's self- With the property set to non-configurable d objetct.freeze (), in addition to being converted to non-extensible, the object's properties are also set to non-configurable, and all data properties are set to read-only (setter method does not affect)-json.stringify () and Json.parse () Serializes and restores objects.

JS Authoritative Guide reading notes (ii)

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.