Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

Javascript

Javascript Problem Overview


This error pops up on my JS console in the browser, and I'm not sure how to interpret the message. Can anyone describe what causes this?

Thanks

Javascript Solutions


Solution 1 - Javascript

This means that you must declare strict mode by writing "use strict" at the beginning of the file or the function to use block-scope declarations.

EX:

function test(){
    "use strict";
    let a = 1;
} 

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionrogerrwView Question on Stackoverflow
Solution 1 - JavascriptOmar ElawadyView Answer on Stackoverflow