let、const、class声明的变量不属于顶层对象★
const USER_NAME = "wangzz";
class A {}
let age = 25;
var job = "coder";
function printInfo() {
console.log("USER_NAME: ", this.USER_NAME);
console.log("age: ", this.age);
console.log("class A", this.A);
console.log("job: ", this.job);
}
printInfo()
// USER_NAME: undefined
// age: undefined
// class A undefined
// job: coder
ES6规定,var命令和function命令声明的全局变量,是顶层对象的属性,但是let、const、class命令声明的全局变量不属于顶层对象的属性
学而不思则罔,思而不学则殆!