What is the major difference between JavaScript declared and undeclared variables, since the delete operator doesn\'t work on declared variables?
var y = 43
The main difference is when you're declaring variables inside a function. If you use var
when you're declaring a variable inside a function, then that variable becomes a local variable. However, if you don't use var
, then the variable becomes a global variable no matter where you declare it (inside or outside a function).