js-Authoritative Guide Study notes 3

Source: Internet
Author: User
Tags bitwise bitwise operators

Fourth chapter expressions and operators

1. The simplest expression is the original expression , which is the smallest unit of an expression-they no longer contain other expressions. The original expression in JS contains constants or direct quantities , keywords , and variables .

2. When the property name of an object is not a fixed value , the property must be accessed using the square bracket notation.

3. Any invocation expression contains a pair of parentheses and an expression before the left parenthesis, which is called a method call If the expression is a property access expression .

4. Side effects of the operator: there are some expressions that have side effects, and before and after expression operations affect each other , such as assignment operators, + + 、--、 Delete operators .

5, Property access Expressions and invocation expressions take precedence over all operators . The assignment operator has a very low priority and is typically executed last.

6, the value of the sub-expression is computed first, and then according to the operator's precedence and binding operations. Assuming there is a a=1, then b= (a++) +a The Calculation Order: 1) Calculation b,2) calculates a++, assuming c,3) calculates a,4) assigns the result of c+a,5 to B. According to the definition of a++, the result of 2nd step is still 1, that is, C=1, then a immediately increases from 1 to 2, so in 3rd step, a=2, the final b=1+2=3.

7, the bitwise operator requires that its operand be an integer. Bitwise is not equivalent to changing one number of symbols and subtracting 1:~5=-6.

8, bitwise operators convert nan/infinity/-infinity to 0.

9,<< left shift , move a number left 1 is equal to it multiplied by 2,>> with the symbol to the right, the equivalent of dividing by 2 (ignoring the remainder). >>> unsigned Right shift , left high always fills 0.

The 10,+ operator prefers a string, and if one of the operands is a string, the string join operation, whereas the comparison operator prefers a number, the string comparison is performed only if the two operands are strings.

11, in operator want its Span style= "COLOR: #ff0000" > The left operand is a string or can be converted to a string , and you want . The expression returns true if the object on the right has a property name called the left operand value. Note that in the array, var data=[7,8,9],7 in data returns false because , not the 7 value in the array.

12, logic and && operators. The left value is computed first, and if the left side evaluates to False, then && simply returns the value of the left operand, not the right operand, or the right operand if the left value evaluates to True ,&& value and returns it as the result of the evaluation of the entire expression, often used for conditional code execution (right after the left condition is satisfied). This behavior is called a "short circuit." Logical OR | | has a similar attribute, if the left value is true, then return this value, if the left value is false, then return the value to the right, often used to give the parameter a default value .

13, ternary operator? : A typical application scenario-- determine whether a variable defines or has a meaningful truth value, uses it if it is meaningful, and uses a default if it is meaningless (similar to | | ).

14. typeof NaN returns "number". typeof null returns "Object".

js-Authoritative Guide Study notes 3

Related Article

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.