Statements and declarations
var declaration
Declares a variable scoped to the surrounding function or applicable top-level context. In an ordinary function the binding is initialized to undefined before body execution; the initializer runs in statement order. An ordinary block does not isolate var. Conflicting lexical declarations can cause early errors.
Formal Syntax & Structure
javascript syntaxjavascript
var name = expression;Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | BindingIdentifier | Name of the binding. |
| expression | expression | Optional initializer evaluated at declaration execution. |
Working Example
Example Snippetjavascript
function amount() { { var n = 11; } return n; }console.log(amount());