ES6: Why do I get this warning on code view

Hi, just curious, I got this error warning on code view:

‘let’ is available in ES6 (use ‘esversion: 6’) or Mozilla JS extensions (use moz)

The error is gone when I changed the declaration from let to var. The code works just fine and no error on dev console.

I just want to know what’s going on and anything about it that I should know.

Thanks in advance for any insight and clarification.

It’s about variable scope

Variables defined with “let” are not added to the global properties of “window” but those defined as “var” are.
So if you define a variable as let myvar = "info"
then console.log(window.myvar) remains undefined

however

If you define a variable as var myvar = "info"
then console.log(window.myvar) is defined

So basically the wappler console cant see variables defined with “let”

2 Likes

OK I’ve been reading about it and my further question is, when it is preferable to use let instead of var, we’ll still get the warning from Wappler js checker. I’m not sure if the code was wrong (it does work and no error on dev console) or the warning is a normal thing.

If I understand how Wappler interacts with the console, it is only because the console cannot read the value that the error is shown.

So I suppose to be more accurate the message should say something like “Console is unable to establish the value of …”, it does not mean that there is an error in the code specifically

From what I’ve read the error has something to do with setting of JSHint. I think it’s the analysis tool used by Wappler.