javascript
let fn = (a) => {
var a = a || 1;
}
var a = a || 1; 改用let写,麻烦一点的写法我会,我想知道有什么高雅的技巧。
let a = a || 1; 会提示: Block scoped variables cannot share name with 'var' variables or parameters in the same block scope
javascript
let fn = (a) => {
var a = a || 1;
}
var a = a || 1; 改用let写,麻烦一点的写法我会,我想知道有什么高雅的技巧。
let a = a || 1; 会提示: Block scoped variables cannot share name with 'var' variables or parameters in the same block scope
同一个作用域内,let声明的变量名不能重复,重复就报错。var没有限制