3. Regarding the temporary dead zone: use typeof to detect an undeclared variable
, the result returned in es5 is undefined but no error is reported
, es6 directly reports an error
"use strict";
console.log(typeof num); //->undefined 当前变量不存在,但是用用typeof检测的时候,不会提示错误,而是返回undefined
console.log(typeof num);//num is not defined
let num; ES6中检测一个没有被声明过的变量直接报错,不像之前ES5中值为undefined一样了
let num;
console.log(typeof num);//只是声明但是没有定义 所以是undefined