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

TypeError: "x" is (not) "y" - 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

TypeError: "x" is (not) "y"

TypeError: "x" is (not) "y"

Examples:
TypeError: "x" is undefined
TypeError: "x" is null
TypeError: "undefined" is not an object
TypeError: "x" is not an object or null
TypeError: "x" is not a symbol

In this article

TypeError.

?

. null undefined.

, , Object.create() Symbol.keyFor(), , .

js
//  undefined  null,    substring   
var foo = undefined;
foo.substring(1); // TypeError: foo is undefined

var foo = null;
foo.substring(1); // TypeError: foo is null

//      
var foo = {};
Symbol.keyFor(foo); // TypeError: foo is not a symbol

var foo = "bar";
Object.create(foo); // TypeError: "foo" is not an object or null

typeof.

js
if (typeof foo !== "undefined") {
  //   ,  foo .
}


Web Proxy Viewer  |  New URL  |  Original Page