Nested functions and knowledge supplement

0407

Nested functions

 

 

 

Knowledge Point added:

   Short-circuit logic: If the first condition has been able to determine the outcome of the whole expression, then the second part is not executed

            && The first condition is false short time

     || The first condition is when the true short circuit

 

For example: var a = 10

       var b = 0

    a > 10 && b === 0

a> 10 false, so the whole expression results have been false, so the back b === 0

This condition will not go to the judge

              a > 0 || b === 0

When the first condition is true, the entire expression is already true, so

The second condition would not go to the judge

   Ternary operator: also referred to as three head operation.

             There are a = 10

              a ++ // one yuan

              a + 2 // two yuan

       //Analyzing conditions ? Condition is met when the execution of the code: The code does not hold

       Example: a> 0 console.log ( 'greater than 0'):? Console.log ( 'less than 0')

           Or console.log (a> 0 'is greater than 0':? 'Is less than 0')

   Statement block of braces:

      语句块:if、switch、while、for、(function)

       Common statement block if there is only one line of code, you can omit the braces

       Generally if else, for some time

       Example: var a = 10

           if (a> 0) console.log ( 'greater than 0');

 

 

Recursive: the function itself calls, unlimited calls but can not, and must have export (to itself)

Recursive configuration conditions should have,

    1. The child must issue the original problem is the same thing, and more simple;

    2. Do not unlimited calling itself, must have an outlet that simplify the situation for non-recursive processing.

Since recursive function is a push itself layer by layer, leading to the stack can not pop, it will cause a stack overflow space filled later.

   Anonymous function: function without a name

      例:function () {

             console.log(123)

}

was test = function () {

                 console.log(123)

}

div.onclick = function () {

                 console.log(123)

}

    IIFE : Since calling a function

         While the function of a package immediately call their own

         Write IIFE time if the code is not in front of the semicolon,

We need to add a semicolon in front IIFE

例:;(function () { console.log(123)})()

         The advantages of reducing global variables. Save memory space

JS run and compile

Gramma analysis

            Find basic grammar there was anything wrong

Pre-parsed

            Pre-parsed before execution

 var, function key to advance to the top of the current scope, the variable default value is undefined, the default value is a function of the function block body,

When a function with the same name as a variable, a function reserved.

Interpreted

       Variable lift:

Example: the variable var declarations to the top of the current scope to improve only statement does not raise assignment

           console.log(a)

There are a = 10

           After completion of the above two lines corresponding to the variable lift following three lines

           There are a

           console.log(a)

           a = 10

       Variable lift is raised to the top of the current scope

    Enhance the function : The function will enhance the function keyword to declare the entire function body to the top of the current scope

 

event:

   Normal mouse event

      click mouse click

       dbclick two mouse clicks triggered event

       Events are displayed when you press the mouse mousedown

       Events displayed when you lift the mouse mouseup

        Events displayed when the mouse moved mouseout

Events displayed when the mouse left mouseover

This will be repeated over and out of the trigger time between the child elements of the box, through, and enter and leave only when the trigger once out of the box

       Events are displayed when the mouse enters mouseenter

       Events displayed when the mouse left mouseleave

       mousemove once every move triggers a move

Guess you like

Origin www.cnblogs.com/52580587zl/p/12661447.html