웹/javascript
typeof, instanceof
by java개발자
2018. 5. 20.
typeof "string" // "string"
typeof 123 // "number"
typeof 1.2 // "number"
typeof 1/0 // NaN ?? typeof 할때 계산은 미리 하고 진행하자. 이상하다.
typeof (1/0) // "number" ??
typeof 0/1 // NaN ??
typeof (0/1) // "number" ??
1/0 // Infinity
typeof Infinity // "number"
typeof false // "boolean"
typeof afssddfd // "undefined"
typeof null // "object" !!!
typeof [] // "object"
typeof new Array("12") // "object"
typeof {} // "object"
typeof new Object() // "object"
typeof function(){} // "function"
typeof alert // "function"
1/0 // Infinity
1-"a" // NaN
1-"12" // -11
//
[1,2] instanceof Object
[1,2] instanceof Array
new String("as") instanceof Object
new String("as") instanceof String
new Boolean("false") instanceof Object
new Boolean("false") instanceof Boolean
"121" instanceof String // false ??
false instanceof Boolean // false ??
"121" instanceof Object // false ??
false instanceof Object // false ??
window instanceof Window
window instanceof Object