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

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

This question is related to javascript

The answer is


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;
}