{
let a = 10;
var b = 1;
}
a // ReferenceError: a is not defined.
b // 1
var tmp = 123;
if (true) {
tmp = 'abc'; // ReferenceError
let tmp;
}
// 报错
function () {
let a = 10;
var a = 1;
}
function f() { console.log('I am outside!'); }
(function () {
if(false) {
// 重复声明一次函数f
function f() { console.log('I am inside!'); }
}
f();
}());
//I am inside! ES5 函数提升
//I am outside! ES6 块级作用域
var a = 1; // 如果在Node的REPL环境,可以写成global.a // 或者采用通用方法,写成this.a window.a // 1 let b = 1; window.b // undefined
const foo='foo'; foo='bar';//TypeError: Assignment to constant variable.
const foo=[]; foo=[1];//Assignment to constant variable.
const foo=[1,2,3]; foo[1]=4; console.log(foo)//[1, 4, 3]
const foo=Object.freeze([1,2,3]); foo[1]=4; console.log(foo)//[1, 2, 3]
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有