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

TypeError: "x" is (not) "y" - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

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

JavaScript "x is (not) y" undefined null

TypeError: Cannot read properties of undefined (reading 'x') (V8 )
TypeError: "x" is undefined (Firefox)
TypeError: "undefined" is not an object (Firefox)
TypeError: undefined is not an object (evaluating 'obj.x') (Safari)

TypeError: "x" is not a symbol (V8  & Firefox)
TypeError: Symbol.keyFor requires that the first argument be a symbol (Safari)

TypeError

undefined null

Object.create() Symbol.keyFor()

undefined null

js
const foo = undefined;
foo.substring(1); // TypeError: foo is undefined

const foo2 = null;
foo2.substring(1); // TypeError: foo2 is null

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

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

null undefined null undefined null

js
if (foo !== undefined && foo !== null) {
  //  foo 
}

foo "" 0

js
if (foo) {
  // foo  null/undefined 
}


Web Proxy Viewer  |  New URL  |  Original Page