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

ReferenceError: "x" is not defined - 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: "x" is not defined

ReferenceError: "x" is not defined

In this article

ReferenceError.

?

, -. , , ( scope).

: ( jQuery), , , "$". <script> .

js
foo.substring(1); // ReferenceError: foo is not defined

"Foo" -. - , String.prototype.substring() .

js
var foo = "bar";
foo.substring(1); // "ar"

. , , .

js
function numbers() {
  var num1 = 2,
    num2 = 3;
  return num1 + num2;
}

console.log(num1); // ReferenceError num1 is not defined.

, , , . , , , .

js
var num1 = 2,
  num2 = 3;

function numbers() {
  return num1 + num2;
}

console.log(num1); // 2


Web Proxy Viewer  |  New URL  |  Original Page