const b = 2; // correct const b; // Error, must initialize Console. log ('const definition outside the function b: '+b)// With output value b = 5; Console. log ('Modify the const definition outside the function b: '+b)// Unable to output
var a = 1; var a; // No error reporting Console. log ('var definition outside the function a: '+a)// Can output a=1 function change(){ a = 4; Console. log ('var definition in function a: '+a)// Can output a=4 } change(); Console. log ('After the function is called, var defines a as the internal modified value of the function: '+a)// Can output a=4
let c = 3; Console. log ('function external let definition c: '+c)// Output c=3 function change(){ let c = 6; Console. log ('let definition in function c: '+c)// Output c=6 } change(); Console. log ('let definition c after function call is not affected by function internal definition: '+c)// Output c=3