| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Errors/Unexpected_type | [Back] [Original] |
Get to know MDN better
TypeError: Cannot read properties of undefined (reading 'x') V8 TypeError: "x" is undefinedFirefox TypeError: "undefined" is not an objectFirefox 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 symbolSafari
Object.create() Symbol.keyFor()
undefined null
const foo = undefined;
foo.substring(1); // TypeError: foo is undefined
const foo2 = null;
foo2.substring(1); // TypeError: foo2 is null
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
undefined null undefined null
if (foo !== undefined && foo !== null) {
// foo
}
if (foo) {
// foo null/undefined
}
This page was last modified on 2025718 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |