Native js-- basis

Js several output statement :?

Alert () dialog box

console.log () console output

document.write () output browser

※ variable's data type ?

① basic data types: String Number Boolean

② complex data types: Object Object

③ special data types: undefind null

※   undefined and Null difference?

Undefined is the value returned when accessing an uninitialized variable, the variable can be seen as empty.

Null is the value of access to the object that has not been present when the return can be seen as an empty object.

※   Switch and if the usage scenarios?

①  When the condition is a specific value, recommended switch

②  When the condition is a range, it is recommended to use if else

※   the while and do ... while difference?

The while : the first determination condition and then performs loop. There loop might never be executed.

Do..while: first iteration of the loop, and then determine the condition, the loop body at least once.

※   BREAK the Continue and return difference?

BREAK : the end of the loop layer, out of the loop body.

The Continue : terminate this cycle, continue to start the next cycle.

The Return : returns, no longer execute the following code.

※   JS parser?

Internal browser has a special parsing JS program where this space is the JS parser interpretation JS program has two steps:

① Pre-analysis:

Find something, var function .

Found var is to find a variable, will advance gives a value for this variable is undefined .

Find function is to find a function that will advance a given value for the function name, the value is a function block itself.

Find two function . If the function the same name, after a pre covering a.

If you find the variables and functions of the same name, retention function.

② progressive interpretation of the code, if you encounter the expression, change the value of a variable, then the value of the variable of the pre-analytic warehouse will change.

※ scope chain?

First look inside the function variable-up, if found inside the body of the function, returns (indicating that the variable is a local variable), otherwise continue to look outside the function body, if the global variable is the operation to find. If the function body inside and outside are not found, this variable to determine whether there is var , anything that is a local variable, then that is not a global variable.

Guess you like

Origin www.cnblogs.com/zd1314/p/12464852.html
Recommended