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

I try to add an Export button in ExtJS, it should do URL encoding for the search parameters and pass the generated query string to the export URL.

When testing above code in Chrome, following error happened:

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


The reason is let keyword is not allowed in non-strict mode for this version of Chrome.

One solution is to change let to var. (But it isn’t good)
The better solution is to add “use strict” statement.

So the final code should be