2 ms·
You must be right. I actually didn't know JS had a "let" (which is different from "var" in that it is block scoped rather than function scoped). It's also qui
by aidenn0 3y ago
You must be right. I actually didn't know JS had a "let" (which is different from "var" in that it is block scoped rather than function scoped). It's also quite different from the let in most Lisps, in that it does not establish a new lexical block.
Playing with it, the binding is scoped to the entire block, but the assignment happens in statement order so that e.g. the following will be an error, rather than logging either "1" or "2" both of which there could be arguments for:
{
let x = 1;
{
console.log(x);
let x = 2;
}
}