|
8 | 8 |
|
9 | 9 |
|
10 | 10 | console.log(typeof "Hello"); // "string" |
| 11 | +console.log(typeof String); // "function" |
| 12 | +console.log(typeof String()); // "string" |
| 13 | +console.log(typeof String("Hello")); // "string" |
| 14 | + |
11 | 15 | console.log(typeof 123); // "number" |
| 16 | +console.log(typeof Number); // "function" |
| 17 | +console.log(typeof Number()); // "number" |
| 18 | +console.log(typeof Number(123)); // "number" |
| 19 | + |
12 | 20 | console.log(typeof true); // "boolean" |
| 21 | +console.log(typeof Boolean); // "function" |
| 22 | +console.log(typeof Boolean()); // "boolean" |
| 23 | +console.log(typeof Boolean(true)); // "boolean" |
| 24 | + |
13 | 25 | console.log(typeof null); // "object" (historical bug in JavaScript) |
| 26 | + |
14 | 27 | console.log(typeof undefined); // "undefined" |
| 28 | + |
| 29 | +console.log(typeof Symbol); // "function" |
15 | 30 | console.log(typeof Symbol()); // "symbol" |
| 31 | +console.log(typeof Symbol("id")); // "symbol" |
| 32 | +console.log(typeof Symbol(123)); // "symbol" |
| 33 | + |
| 34 | +console.log(typeof BigInt); // "function" |
| 35 | +console.log(typeof BigInt()); // TypeError - Cannot convert undefined to BigInt |
| 36 | +console.log(typeof BigInt("123")); // "bigint" |
16 | 37 | console.log(typeof BigInt(123)); // "bigint" |
| 38 | + |
17 | 39 | console.log(typeof { name: "Hitarth", age: 24, single: true }); // "object" |
| 40 | +console.log(typeof Object); // "function" |
| 41 | +console.log(typeof Object()); // "object" |
| 42 | +console.log(typeof Object({ name: "Hitarth", age: 24, single: true })); // "object" |
| 43 | + |
18 | 44 | console.log(typeof [1, 2, 3]); // "object" |
| 45 | +console.log(typeof Array); // "function" |
| 46 | +console.log(typeof Array()); // "object" |
| 47 | +console.log(typeof Array(1, 2, 3)); // "object" |
| 48 | + |
19 | 49 | console.log(typeof function () { }); // "function" (special case - bacause they are callable objects) |
| 50 | +console.log(typeof Function); // "function" |
| 51 | +console.log(typeof Function()); // "function" |
| 52 | +console.log(typeof Function(() => { })); // "function" |
| 53 | + |
| 54 | +console.log(typeof Date); // "function" |
| 55 | +console.log(typeof Date()); // "string" |
| 56 | +console.log(typeof new Date()); // "object" |
| 57 | + |
| 58 | +console.log(typeof RegExp); // "function" |
| 59 | +console.log(typeof RegExp()); // "object" |
| 60 | + |
| 61 | +console.log(typeof Map); // "function" |
| 62 | +console.log(typeof Map()); // TypeError - Constructor Map requires 'new' |
| 63 | +console.log(typeof new Map()); // "object" |
| 64 | + |
| 65 | +console.log(typeof Set); // "function" |
| 66 | +console.log(typeof Set()); // TypeError - Constructor Set requires 'new' |
| 67 | +console.log(typeof new Set()); // "object" |
| 68 | + |
| 69 | +console.log(typeof Error); // "function" |
| 70 | +console.log(typeof Error()); // "object" |
| 71 | + |
| 72 | +console.log(typeof Math); // "object" |
| 73 | + |
| 74 | +console.log(typeof JSON); // "object" |
| 75 | + |
| 76 | +console.log(typeof Promise); // "function" |
| 77 | +console.log(typeof Promise()); // TypeError - Constructor Promise cannot be invoked without 'new' |
| 78 | +console.log(typeof new Promise()); // TypeError - Promise Resolver undefined is not a Function |
| 79 | +console.log(typeof new Promise(() => { })); // "object" |
20 | 80 |
|
21 | 81 |
|
22 | 82 |
|
|
0 commit comments