---
id: javascript-typeof
title: "JavaScript typeof"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["JS typeof", "typeof operator", "type checking", "Array.isArray", "instanceof"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.89
created_at: 2026-06-23
updated_at: 2026-06-23
review_reason: ""
merge_history: []
tags: ["javascript", "js", "web", "frontend", "w3schools", "typeof", "type-checking", "instanceof"]
raw_sources: ["https://www.w3schools.com/js/js_typeof.asp"]
applied_in: []
github_commit: ""
---

# [[JavaScript typeof]]

## 🎯 한 줄 통찰 (One-line insight)
The `typeof` operator returns the data type of a variable or expression; it distinguishes the 7 primitives but collapses all complex data to `"object"` or `"function"` — so `Array.isArray()`, `instanceof`, and `constructor` are needed to tell object types apart. [S1]

## 🧠 핵심 개념 (Core concepts)
- **`typeof` returns a type string** — it returns the data type of a variable or expression. [S1]
- **7 primitive types** — `typeof` distinguishes: string, number, boolean, bigint, symbol, null, undefined. [S1]
- **`typeof null` is `"object"`** — a well-known bug: `typeof null` returns `"object"` even though `null` is a primitive. [S1]
- **Complex data collapses to two labels** — for complex data, `typeof` returns only `"object"` or `"function"`. [S1]
- **Use other checks for object types** — `Array.isArray()` detects arrays; `instanceof` and the `constructor` property identify specific object types like Date, Array, Map, and Set. [S1]

## 🧩 추출된 패턴 (Extracted patterns)
- **`Array.isArray(x)`** — the reliable way to check whether a value is an array. [S1]
- **`x instanceof Type`** — checks whether `x` is an instance of a constructor such as `Date`, `Array`, `Map`, or `Set`. [S1]
- **`x.constructor === Type`** — compare a value's `constructor` property to identify its object type. [S1]

## 📖 세부 내용 (Details)
**The `typeof` Operator**
The `typeof` operator returns the data type of a variable or expression. [S1]

**Primitive Data Types**
JavaScript has 7 primitive types: string, number, boolean, bigint, symbol, null, and undefined. [S1]
```javascript
typeof "John"         // Returns string
typeof ("John"+"Doe") // Returns string
typeof 3.14           // Returns number
typeof 33             // Returns number
typeof (33 + 66)      // Returns number
typeof true           // Returns boolean
typeof false          // Returns boolean
typeof 1234n          // Returns bigint
typeof Symbol()       // Returns symbol
typeof x              // Returns undefined
typeof null           // Returns object
```

**Complex Data Types**
The `typeof` operator returns only two types for complex data: `"object"` and `"function"`. [S1]
```javascript
typeof {name:'John'}   // Returns object
typeof [1,2,3,4]       // Returns object
typeof new Map()       // Returns object
typeof new Set()       // Returns object
typeof function (){}   // Returns function
```

**Undefined & Empty Values** [S1]
```javascript
let car;
typeof car;  // "undefined"
```
```javascript
let car = "";
typeof car;  // "string"
```

**Null vs Undefined** [S1]
```javascript
typeof undefined;      // "undefined"
typeof null;           // "object"
null === undefined;    // false
null == undefined;     // true
```

**`Array.isArray()`** — detect arrays reliably: [S1]
```javascript
const fruits = ["apples", "bananas", "oranges"];
Array.isArray(fruits);  // true
```

**The `instanceof` Operator** — identify specific object types: [S1]
```javascript
const time = new Date();
(time instanceof Date);  // true
```
```javascript
const fruits = ["apples", "bananas", "oranges"];
(fruits instanceof Array);  // true
```
```javascript
const fruits = new Map([
  ["apples", 500],
  ["bananas", 300],
  ["oranges", 200]
]);
(fruits instanceof Map);  // true
```
```javascript
const fruits = new Set(["apples", "bananas", "oranges"]);
(fruits instanceof Set);  // true
```

**The `constructor` Property** — another way to identify object types: [S1]
```javascript
{name:'John',age:34}.constructor        // Object
[1,2,3,4].constructor                   // Array
new Date().constructor                  // Date
new Set().constructor                   // Set
new Map().constructor                   // Map
function () {}.constructor              // Function

// Check if array:
(myArray.constructor === Array);

// Check if date:
(myDate.constructor === Date);
```

## 🛠️ 적용 사례 (Applied in summary)
The page's own snippets are the canonical applied examples — `typeof` on every primitive and complex type, plus `Array.isArray()`, the `instanceof` checks for Date/Array/Map/Set, and the `constructor` comparisons. No external project/commit applications found in the source.

## 💻 코드 패턴 (Code patterns)
Detect an array (language: JavaScript):
```javascript
Array.isArray(fruits);  // true
```
Identify a specific object type:
```javascript
(time instanceof Date);          // true
(myDate.constructor === Date);   // true
```

## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
- **`typeof` vs `Array.isArray()` vs `instanceof` vs `constructor`** — `typeof` is best for distinguishing primitives but cannot tell apart arrays, maps, sets, or dates (all `"object"`). Use `Array.isArray()` specifically for arrays, and `instanceof` or `.constructor === Type` to identify other object types. [S1]
- **`===` vs `==` for null/undefined** — `null === undefined` is `false` (different types), while `null == undefined` is `true` (loose equality treats them as equal). [S1]

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
`typeof null` returns `"object"`, which the page identifies as a well-known bug rather than the expected primitive result. [S1]

## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.89
- **중복 검사 결과:** 신규 생성 (New discovery)

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[JavaScript Tutorial]]
- **관련 개념:** [[JavaScript Data Types]], [[JavaScript Primitive Data Types]], [[JavaScript Object Data Types]], [[JavaScript Symbols]]
- **참조 맥락:** Referenced whenever inspecting or validating the type of a value at runtime.

## 📚 출처 (Sources)
- [S1] W3Schools — JavaScript typeof — https://www.w3schools.com/js/js_typeof.asp

## 📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript typeof" page (Astra wiki-curation, P-Reinforce v3.1 format).
