Identifier ‘‘ has already been declared,变量重定义/重新声明/重复声明,chrome devtool console中的特殊的行为

console,一次性输入进去
var xxxx = 2;
var xxxx = 3;
可以

let yyyy = 2;
let yyyy = 3;
Uncaught SyntaxError: Identifier 'yyyy' has already been declared
分两次输入console,可以

var mmmm = 2;
let mmmm = 3;
Uncaught SyntaxError: Identifier 'mmmm' has already been declared
分两次输入console,Uncaught SyntaxError

let tttt = 2;
var tttt = 3;
Uncaught SyntaxError: Identifier 'tttt' has already been declared
分两次输入console,Uncaught SyntaxError

查了一会,中文似乎没提这个的,这是chrome的一个独特特性

https://dev.to/cooldashing24/chrome-now-allows-for-let-and-class-redeclarations-in-the-console-2m0f

https://developer.chrome.com/blog/new-in-devtools-92/#const-redeclaration

你可能感兴趣的:(javascript,前端,html)