Grammar Tree vs Priority

  • Grammar

    • Grammar Tree vs Priority syntax Tree and operator
    • Left hand side & Right Hand side operators lvalue and rvalue
  • Tree vs Priority

    • + —3
    • * /–2
    • () — — —1
  • Expression

    • The Member operation has the highest priority

      • A.b ——– member access
      • A [b] ——- Member access support runtime
      • foo`tring`
      • super.b —-class
      • super[‘b’]
      • new.target
      • New Foo()- bracketed new takes precedence over unbracketed new
      3 > 2 &&2 > 1 //return true3 > 2 > 1 // ReturnfalseBecause 3 > 2 istrueAnd,true > 1 is false// use parentheses to make it clearer :(3 > 2) >Copy the code
    • Call is lower than new and Member

      • Foo () base Call Expression
      • super()
      • Foo ()[‘b’] degrades Call Expression
      • Foo ().b degrades Call Expression
      • foo()abcThe drop Call Expression
  • Reference Type A type in a standard

    • Object

    • The Key can be a string or symbol

      The Reference type retrieves an Object and a Key

    • delete

    • assign

  • Left hand side and Right hand side

    Left hand side is on the Left, Right hand side is on the Right

    Left hand Expression must be Right hand Expression (there are no exceptions in JavaScript)

    a.b = c; A + b = cCopy the code
    • Updata Expression Autoincrement and subtraction cannot be placed on the left side of the equal sign

      • a++
      • a–
      • –a
      • ++a
    • Unary Expression Unary Expression

      • delete a.b
      • Void foo() undefined changes the syntax structure
      • typeof a
      • +a does not change the value of the expression; if it is followed by a string, type conversions occur
      • -a
      • ~a bit Operation The integer is reversed by bit and is not an integer
      • ! A non – operations for Boolean operations two!! Casts a number to a Boolean type
      • await a
    • Multiplicative

      • * / % multiply and divide remainder
    • Addtive

      • + – add and subtract
    • Shift

      • << >> >>> move left move right
    • elationship

      • < > <= >= instanceof in relation comparison

        String dictionary order

    • Equality is equal

      • == Converts Boolean variables to number first
      • ! =
      • = = =
      • ! = =
    • Bitwise bit operations

      • & ^ | and bitwise or by location
    • Short-circuit principle of Logical operations

      • &&
      • ||
    • Conditional ternary operator

      • ? :
  • Exponental right operator ** exponents

    Javascript’s only right associative operator 3**2**3 = 3**8

Run-time conversions and reference types

  • Runtime

    • Type Convertion
    • Reference
  • Type Convertion Type conversion

    false' == false // false
    ''== false // true '  '== false // true Number(' ') //0 Number('') //0 Number(false) //0Copy the code

    If the two types of == are different, convert them to Number for comparison. Therefore, === is recommended.

  • Unboxing conversion

  • Boxing box conversion

Run-time related concepts

  • The Statement Statement

    • Grammar
      • Simple statements do not accommodate other statements

        • ExpressionStatement
        • EmptyStatement EmptyStatement ‘; ‘
        • DebuggerStatement breakpoint debugger;
        • ThrowStatement throws an exception throw, space, and expression
        • ContinueStatement matches the loop statement to end a single loop and continue the loop
        • BreakStatement matches loop statements to end a single loop and end the entire loop
        • Used in the ReturnStatement function, which returns the value of the function
      • Compound statement

        • BlockStatement {Statement list} Change a single statement into multiple statements

        • IfStatement Conditional statement
        • SwitchStatement multi-branch structure, not recommended in JavaScript, use if instead
        • IterationStatement represents multiple statements, while, do while,for,for await
        • WithStatement opens an object with with, which puts all of its properties directly into scope
        • LabelledStatement
        • TryStatement try catch Finally
      • The statement

  • The statement

    • FunctionDeclaration The function declares four modes

      • The generator function * statement
      • Async Function Async function declaration
      • Async Function * Async generator
    • GeneratorDeclaration GeneratorDeclaration

    • AsyncFunctionDeclaration Asynchronous function declaration

    • AsyncGeneratorDeclaration asynchronous generator

    • VariableStatement variable declarations can be declared and computed

    • ClassDeclaration class declaration

    • LexicalDeclaration const let

      Function, function*, async function, async function*, var scope function body, no order, as the first line. Class, const, let declaration before call error (suggestion)

  • Pretreatment of the pre – process

    The javascript engine preprocesses the code before it is executed. Var is pre-declared at the function level no matter where it is written in the function, after the return in the if, and finally in the catch.

  • scope

  • The runtime

    • Completion Record A Record of the result of the execution of a statement
      if(x == 1)
          return 10;
      Copy the code
      • [[type]]:normal,break,continue,renturn,or throw
      • [[value]]: basic type
      • [[target]]:label
    • Lexical context scope

Js structured macro and micro tasks

JS performs granular (runtime) macro and micro tasks