1, about the return in the function:
When you use the return statement, the function stops execution and returns the specified value.
Syntax function myFunction ()
{
var x=5;
return x;
}
The above function will return a value of 5
Note: the entire JavaScript does not stop executing, just the function. JavaScript will continue to execute code from where the function is called.
2, JS about
Scope:
Domain: Range, area, space
Function: Read, write (personal understanding is to perform some action, operation, or understanding as effective)
The following paragraph means that the browser treats JS work principle, here assume that there is a "JS parser", when it encountered the "<script>" this label, it will get up to work, before the work, to do a pre-analysis: For example, to find "var" "function" To prepare for work, and then to parse the code on a row-by-line basis;
Browser:
/* "JS parser"
1) "Find something": var function parameter
A = ...
All variables, before formally running the code, assign a value in advance: Undefined, so for a variable that does not have an assignment, it returns undefined
FN1 = function fn1 () {alert (2);}
All functions, before the code is formally run, are the entire function block.
Pre-parsing of JS
Encounter duplicate name: leave only one
Variables and functions have the same name, leaving only the function
2) Read the Code by line:
Expression: = +-*/% + +--! Parameters ...//These meta operators are expressions
An expression can modify a pre-parsed value! */
Scope-js Learning note 2015-6-8 (52nd Day)