Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions files/en-us/web/javascript/reference/statements/var/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ function a() {}
console.log(a); // 1
```

A `var` declaration without an initializer does not overwrite the function's value.

```js
function foo() {
console.log(typeof a); // "function"
var a;
function a() {}
console.log(typeof a); // "function"
}

foo();
```

`var` declarations cannot be in the same scope as a {{jsxref("Statements/let", "let")}}, {{jsxref("Statements/const", "const")}}, {{jsxref("Statements/class", "class")}}, or {{jsxref("Statements/import", "import")}} declaration.

```js-nolint example-bad
Expand Down