[Record] vue related knowledge

  • let
let es6 command is newly introduced, and the like var command, but let local variables declared valid only where the code block. 

ES5 only global scope and function scope, not block-level scope, which bring a lot of irrational scenes. 

S = var 'Hello'; 
 
for (var i = 0; i <s.length; i ++) { 
  the console.log (S [i]); 
} 
 
the console.log (i); //. 5 

above code, the variable i only used to control the loop, but the loop is finished, it has not disappeared, disclosure has become a global variable. 

 

  • const
const Declares a read-only constant. Once declared, the value of the constant can not be changed. 

const PI = 3.1415; 

if the declaration is not only assignment will error

  

 

 

Guess you like

Origin www.cnblogs.com/wbl001/p/11443891.html