1. What is it?
Thelet
statement declares a block scope local variable, optionally initializing it to a value. and use in ECMA 5.2. How to use it
if (x > y) {
let gamma = 12.7 + y;
i = gamma * x;
}
3. Compare
I: Local variableVariables declared within a JavaScript function,
become LOCAL to the function.
Local variables have local scope: They can only be accessed within the function
// Example
II: Global variable
A variable declared outside a function, becomes GLOBAL
// Example
var pi = 3.14;
var person = "John Doe";
var answer = 'Yes I am!';
REF
MSDN
沒有留言:
張貼留言