简体   繁体   English

由于默认情况下未启用严格模式,如何在chrome dev工具中访问'let'关键字?

[英]how 'let' keyword is accessible inside chrome dev tool as strict mode is not enabled by default?

I have tried to declare a variable inside chrome dev tool console using let keyword and it didn't give me any error. 我试图使用let关键字在chrome dev工具控制台中声明一个变量,但它没有给我任何错误。 But I heard that let keyword is only available in 'strict mode' and in dev tool strict mode is disabled. 但我听说let关键字仅在“严格模式”下可用,而在开发工具严格模式下已禁用。

let name = 'john';
console.log(name);

I think you have a misunderstand: 我认为您有一个误解:

The purpose of "use strict" is to indicate that the code should be executed in "strict mode". “使用严格”的目的是指示应在“严格模式”下执行代码。 With strict mode, you can not, for example, use undeclared variables. 在严格模式下,例如,您不能使用未声明的变量。

And let is new keyword from ES2015, it can be use without strict mode. let是ES2015的新关键字,可以在没有严格模式的情况下使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM