- Scope:
- Function-scoped: Variables declared with
var
are scoped to the function in which they are declared.
- Not block-scoped:
var
variables are not confined to the block in which they are declared (e.g., inside a loop or if
statement).
- Hoisting:
var
declarations are hoisted to the top of their scope (function or global) but are initialized with undefined
.
- Re-declaration:
var
allows re-declaration within the same scope.
- Global Object Property:
- When declared globally,
var
variables become properties of the global object (window
in browsers).