JS: Language essence Note 2--expression

Source: Internet
Author: User

Word form operator : Typeof,in,void,instanceof,new,delete.

expression : consists of an operator and an operator, an expression that has no operator in JS is called a single-value expression, and an operator that is orphaned from the code context is not syntactically compliant;

Single-Value expressions:

    • this reference;
    • variable reference;
    • Direct Volume:
      • Null
      • Undefined
      • String
      • Boolean value
      • Numerical
      • Regular expressions

Basic expression:

    • Single-Value expressions
    • Array initializer: []
    • Object initializer: {}
    • Expression Grouping operations: ()

Operators are categorized by result values:

    • General expression Operations: (Coercion of type conversions)
      • Numeric operations
      • Bit arithmetic
      • Boolean operation (! && | | )
    • Value logical operation: (the primitive is interpreted as a Boolean value but does not enforce a type conversion) (&& | | )
    • String operations
      • String Connection: The effect is the same as concat ();
    • Equivalence operation: (high cost for string detection in three types of value)
    • Assignment operation:
      • general assignment;
      • compound assignment; (not for string operations except + =)
    • Function call: Use parentheses to pass arguments and execute;
      • General function functions call;
      • Function object invocation created by the functions class;
    • Objects: creating, accessing, checking, etc.;
    • Other

sequence detection (in equivalence operation):

    • The type of the sequence can be compared: Boolean,string,number (any value that compares to Nan returns false because it does not have a sequence value)
    • Detection rules: (by numerical comparison priority principle)
      • Two value type comparison: Compare the size of the sequence;
      • Reference types compared to value types: reference types are converted to value type data of the same type after comparison;
      • Two reference type comparisons: Meaningless, always returning false, because the sequence cannot be found;

Assignment Operation : The effect of assignment is to modify the value in the storage unit;

      • The syntax of "100 = 10" so that the assignment is set up, but the execution time will be due to the left side of the operator is a direct volume, its storage unit is not writable and lead to errors;
      • Special case: Because the value type string is an indeterminate length of continuous data block, the assignment cost is large, so the string in JS is assigned to the address reference of the string;
        • String characters cannot be modified directly;
        • A string join operation produces a new string;
        • Modify length meaningless;

Special operators:

    • does not directly produce the operation effect but affects the operation effect:
      • void: Causes an expression to always return undefined;
      • ? :
      • (): Adjust the order of operations, priority arithmetic
      • ,: Sequential execution of an expression
    • Do not directly target the value of a variable but for a variable operation:
      • typeof: Does not access the value of the variable, but the value of the type information, so the use of undefined variables will not be error;
      • Instanceof: Returns the inheritance relationship;
      • In: Returns the member relationship;
      • Delete: Remove members;

JS: Language essence Note 2--expression

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.