我定义了一个变量,并为其分配了一个语法错误的函数。它引发错误。现在,我无法对任何变量使用该变量,它总是说'Thrown: ReferenceError:变量未定义'
> let bg = 'asasas-123d'
undefined
> let fd = bg.substring(indexOf('-')+1)
Thrown:
ReferenceError: indexOf is not defined
> let fd = bg.substring(bg.indexOf('-')+1)
Thrown:
SyntaxError: Identifier 'fd' has already been declared
> fd = bg.substring(bg.indexOf('-')+1)
Thrown:
ReferenceError: fd is not defined
> let fd = bg.substring(bg.indexOf('-')+1)
Thrown:
SyntaxError: Identifier 'fd' has already been declared
> fd = bg.substring(bg.indexOf('-')+1)
Thrown:
ReferenceError: fd is not defined
> fd
Thrown:
ReferenceError: fd is not defined
> console.log(fd);
Thrown:
ReferenceError: fd is not defined
答案 0 :(得分:0)
只需重新启动终端并运行以下命令即可:
> let bg = 'asasas-123d'
> let fd = bg.substring(bg.indexOf("-") + 1))