let to declare a variable. However, they are not understood the same. The differences between them are scope.
var is function scoped while
let is block scoped.
If a variable is defined with
let in later code block, it returns an error of no exist variable, while it returns
undefined (declared but no value) with
Example of var
console.log(book); var book = 'Learn Flutter'; console.log(book);
Example of let
console.log(book); let book = 'Learn Kotlin'; console.log(book);