[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Errors/Undeclared_var [Back]  [Original]

ReferenceError: assignment to undeclared variable "x" - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

ReferenceError: assignment to undeclared variable "x"

ReferenceError: assignment to undeclared variable "x" (Firefox)
ReferenceError: "x" is not defined (Chrome)
ReferenceError: Variable undefined in strict mode (Edge)

In this article

ReferenceError .

?

. , var. , , JavaScript .

:

  • , . .
  • . , .
  • - ( ). (, ).

.

Errors about undeclared variable assignments occur in strict mode code only. In non-strict code, they are silently ignored.

"bar" .

js
function foo() {
  "use strict";
  bar = true;
}
foo(); // ReferenceError: assignment to undeclared variable bar

"bar" , var .

js
function foo() {
  "use strict";
  var bar = true;
}
foo();


Web Proxy Viewer  |  New URL  |  Original Page