Some people ask a lot, is there a diffrence between the
var keyword and the
let keyword? Well, yes, there is.
var to declare variables, to use them with our program.
But then you'll tell me: "If we declare variables with both, why there is a diffrence?".
Ok, have an example:
s is undefined? Well because we use
let to declare variables in brackets or we can just call them local variables.
You can't use it outside the brackets that it is declared in.
But with var:
var, you declare global variables which you can use it anywhere (of course not outside a function or a class).
I hope you enjoyed this tutorial, have a great day!