var (legacy)
Old variable declaration (now let/const is preferred).
Syntax
var name = value;
Description
var is JavaScript's old variable declaration. Since its scope rules are confusing, it has been replaced by let and const in modern code.
Example
Loading editor…
Expected output
5
When to use?
You will see it in old code; write let/const in new code.