This is mainly to preserve compatibility with B4X. After all, BANano does not try to mimic JavaScript but rather allows you to write normal B4X code (using its syntax rules) without having to worry about JavaScript specific rules. The "Let" scope rules in JavaScript are not that simple, especially when someone is not used to it in B4X.
In B4X, this is allowed for example:
Dim x as String = "Hello"
Dim x as String = "Goodbye"
Lucky, in JavaScript var does allow this too:
var x = "Hello";
var x = "Goodbye";
Let does not allow that:
let x = "Hello";
let x = "Goodbye"; // error, x was already declared
There is also no "Let" keyword in B4X. So that would mean one would have to declare such a variable as something like:
BANano.Let("x", "Hello")
' and get it
log(BANano.Get("x"))
' and I wouldn't even know how to use it in a For loop declaration for example without the IDE throwing errors.
which, besides looking silly, breaks with how normal B4X variables are declared. And the B4X IDE would not throw an error if you misused it in scope, because this concept does not exist here.
Const is supported in BANano, in the sense that it does not throw an error when transpiling. You can use it in your B4X code, and it will throw an error in the B4X IDE if you try to change it. Once generated to JavaScript, it is stripped, as it doesn't really matter anymore (nowhere in your code will you try to reassign its value as it was not allowed in the IDE).
"Let" was introduced to solve a problem
in JavaScript that does not exist in B4X. And not having it has the advantage it allows BANano also to transpile for ES5 too.
BANano allows
B4X coders to write JavaScript in the
B4X syntax, which is the point of this whole exercise.
Alwaysbusy