Baseline Widely available
typeof
ì°ì°ìë í¼ì°ì°ìì íê° ì ìë£íì ëíë´ë 문ìì´ì ë°íí©ëë¤.
console.log(typeof 42);
// Expected output: "number"
console.log(typeof "blubber");
// Expected output: "string"
console.log(typeof true);
// Expected output: "boolean"
console.log(typeof undeclaredVariable);
// Expected output: "undefined"
구문
typeof
ì°ì°ìë í¼ì°ì°ì ìì ìì¹í©ëë¤.
typeof operand;
typeof (operand);
매ê°ë³ì
operand
ìë£íì ê°ì ¸ì¬ ê°ì²´ ëë ììê°ì ëíë´ë ííì.
typeof
ê° ë°íí ì ìë ê°ì ìë íìì ë³¼ ì ììµëë¤. ìë£íê³¼ ììê°ì ëí ìì¸í ì ë³´ë JavaScript ìë£íê³¼ ìë£êµ¬ì¡° íì´ì§ë¥¼ ì°¸ê³ íì¸ì.
"undefined"
Null "object"
(ìë ì°¸ê³ ) Boolean "boolean"
Number "number"
BigInt "bigint"
String "string"
Symbol (ECMAScript 2015ìì ì¶ê°) "symbol"
í¸ì¤í¸ ê°ì²´ (JS íê²½ìì ì ê³µ) 구íì²´ë§ë¤ ë¤ë¦ Function ê°ì²´ (ECMA-262 ííì¼ë¡ë [[Call]]ì 구ííë ê°ì²´) "function"
ë¤ë¥¸ 모ë ê°ì²´ "object"
ì°¸ê³ : ECMAScript 2019 and older permitted implementations to have typeof
return any implementation-defined string value for non-callable non-standard exotic objects.
The only known browser to have actually taken advantage of this is old Internet Explorer (see below).
ìì // Numbers
typeof 37 === "number";
typeof 3.14 === "number";
typeof Math.LN2 === "number";
typeof Infinity === "number";
typeof NaN === "number"; // Despite being "Not-A-Number"
typeof Number(1) === "number"; // but never use this form!
typeof 42n === "bigint";
// Strings
typeof "" === "string";
typeof "bla" === "string";
typeof typeof 1 === "string"; // typeof always returns a string
typeof String("abc") === "string"; // but never use this form!
// Booleans
typeof true === "boolean";
typeof false === "boolean";
typeof Boolean(true) === "boolean"; // but never use this form!
// Symbols
typeof Symbol() === "symbol";
typeof Symbol("foo") === "symbol";
typeof Symbol.iterator === "symbol";
// Undefined
typeof undefined === "undefined";
typeof declaredButUndefinedVariable === "undefined";
typeof undeclaredVariable === "undefined";
// Objects
typeof { a: 1 } === "object";
// use Array.isArray or Object.prototype.toString.call
// to differentiate regular objects from arrays
typeof [1, 2, 4] === "object";
typeof new Date() === "object";
// The following is confusing. Don't use!
typeof new Boolean(true) === "object";
typeof new Number(1) === "object";
typeof new String("abc") === "object";
// Functions
typeof function () {} === "function";
typeof class C {} === "function";
typeof Math.sin === "function";
ì¶ê° ì ë³´ null
// This stands since the beginning of JavaScript
typeof null === "object";
JavaScript를 ì²ì 구íí ë, JavaScript ê°ì íì
íê·¸ì ê°ì¼ë¡ íìëììµëë¤. ê°ì²´ì íì
íê·¸ë 0ì´ììµëë¤. null
ì Null pointer(ëë¶ë¶ì íë«í¼ìì 0x00
)ë¡ íìëììµëë¤. ê·¸ ê²°ê³¼ nullì íì
íê·¸ë¡ 0ì ê°ì§ë©°, ë°ë¼ì typeof
ë object를 ë°íí©ëë¤. (ì°¸ê³ ë¬¸ì)
ECMAScriptì ìì ì´ ì ì(opt-inì íµí´)ëìì¼ë ê±°ì ëììµëë¤. ì ìë ê²ì ë¤ìê³¼ ê°ìµëë¤. typeof null === 'null'.
Callable regular expressions were a non-standard addition in some browsers.
typeof /s/ === "function"; // Chrome 1-12 Non-conform to ECMAScript 5.1
typeof /s/ === "object"; // Firefox 5+ Conform to ECMAScript 5.1
ëª
ì¸ì ë¸ë¼ì°ì í¸íì± IE ì°¸ê³ ì¬í
On IE 6, 7, and 8 a lot of host objects are objects and not functions. For example:
typeof alert === "object";
ê°ì´ 보기
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