How can i use ES6 syntax such as let in chrome console? [duplicate]
UPDATE: As of late 2019, you can just use let
in the console.
As the error message states, some ES6 features are not available outside of strict mode. Therefore, to take advantage of those features, you must first create a strict-mode block.
From the console, the easiest way to use strict mode is by creating an Immediately-Invoked Function Expression (IIFE). For example,
(function() { "use strict"; let x = "asdf"; }());
will behave as intended when entered in the console.