If I have something like:
let x = 20;
var z = 20;
will
x === z
Answer
Try it out and see for yourself...
(If nothing is displayed that is because you are using a browser that doesn't support let.)
"use strict";
let x = 20;
var z = 20;
document.write(x === z);Read this answer for details about the differences between let and var:
The difference is scoping.
varis scoped to the nearest function block (or global if outside a function block), andletis scoped to the nearest enclosing block (or global if outside any block), which can be smaller than a function block.
No comments:
Post a Comment