August 2017
Beginner
298 pages
7h 4m
English
Next, we have the let keyword. ES6 has two new keywords for declaring variables, let and const. let and var differ by the scope of the variables declared using them. The scope of variables declared using var is within the function it is defined and global if it is not defined inside any function, while the scope of let is restricted to within the enclosing block it was declared in and global if it is not defined inside any enclosing block. Look at the following code:
var toDo;window.addEventListener("load", () => { var toDo = new ToDoClass();});
If you were to accidentally re-declare toDo somewhere along the code, as follows, your class object gets overwritten:
var toDo = "some value";
This behavior is confusing and quite ...
Read now
Unlock full access