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 symbolError type What went wrong?
ê·¸ê²ì ì ííì§ ìì ííì´ë¤. ê·¸ê²ì ê°ëundefined
ë null
ê°ì ë°ìíë¤.
ëí, Object.create()
ëë Symbol.keyFor()
ì ê°ì ë©ìëë ë°ëì ì ê³µëì´ì¼íë í¹ë³í íí를 ì구íë¤.
// undefined and null cases on which the substring method won't work
var foo = undefined;
foo.substring(1); // TypeError: foo is undefined
var foo = null;
foo.substring(1); // TypeError: foo is null
// Certain methods might require a specific type
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
Fixing the issue
undefined ë null ê°ì ê°ì§ null í¬ì¸í°ë¥¼ ê³ ì¹ê¸° ìí´ì ìë ìì ì ê°ì´ typeof ì°ì°ì를 ì¬ì©í ì ìë¤.
if (typeof foo !== "undefined") {
// Now we know that foo is defined, we are good to go.
}
ê°ì´ 보기
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4