---
id: javascript-types
title: "JavaScript Types"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["JavaScript Datatypes", "JS data types", "JS types", "typeof", "JavaScript 8 data types", "primitive types"]
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", "types", "typeof"]
raw_sources: ["https://www.w3schools.com/js/js_types.asp"]
applied_in: []
github_commit: ""
---

# [[JavaScript Types]]

## 🎯 한 줄 통찰 (One-line insight)
A JavaScript variable can hold 8 types of data — String, Number, BigInt, Boolean, Object, Undefined, Null, and Symbol — and the `typeof` operator returns the type of any variable or expression as a string. [S1]

## 🧠 핵심 개념 (Core concepts)
- **8 data types** — A JavaScript variable can hold 8 types of data: String, Number, BigInt, Boolean, Object, Undefined, Null, and Symbol. [S1]
- **`typeof` operator** — You can use the `typeof` operator to find the type of a JavaScript variable; it returns the type of a variable or an expression as a string. [S1]
- **Strings use quotes** — A string is a series of characters like "John Doe", written with single or double quotes; quotes inside a string work if they differ from the surrounding quotes. [S1]
- **Numbers are floating point** — All JavaScript numbers are stored as decimal numbers (floating point), and extra large/small numbers can use exponential notation. [S1]
- **Booleans are the basis of comparisons** — Booleans can only have `true` or `false`, and all comparison operators return `true` or `false`. [S1]
- **`undefined` vs empty** — A variable declared without a value has the datatype `undefined`; an empty string is unrelated to `undefined` — it has both a legal value and the type `"string"`. [S1]

## 🧩 추출된 패턴 (Extracted patterns)
- **Probe a type with `typeof`** — Prefix any value or expression with `typeof` to read back its type as a string (e.g. `typeof (3 + 4)` returns `"number"`). [S1]
- **Quote nesting** — Embed a quote character inside a string by surrounding the string with the opposite quote style (`"It's alright"`, `'He is called "Johnny"'`). [S1]
- **Exponential literals** — Write very large or very small numbers compactly with `e` notation (`123e5`, `123e-5`). [S1]

## 📖 세부 내용 (Details)
**JavaScript has 8 Datatypes** [S1]
A JavaScript variable can hold 8 types of data:

| Type | Description |
|------|-------------|
| String | A text of characters enclosed in quotes |
| Number | A number representing a mathematical value |
| Bigint | A number representing a large integer |
| Boolean | A data type representing true or false |
| Object | A collection of key-value pairs of data |
| Undefined | A primitive variable with no assigned value |
| Null | A primitive value representing object absence |
| Symbol | A unique and primitive identifier |

Examples of values of each type: [S1]
```javascript
// String
let color = "Yellow";
let lastName = "Johnson";

// Number
let length = 16;
let weight = 7.5;

// BigInt
let x = 1234567890123456789012345n;
let y = BigInt(1234567890123456789012345)

// Boolean
let x = true;
let y = false;

// Object
const person = {firstName:"John", lastName:"Doe"};

// Array object
const cars = ["Saab", "Volvo", "BMW"];

// Date object
const date = new Date("2022-03-25");

// Undefined
let x;
let y;

// Null
let x = null;
let y = null;

// Symbol
const x = Symbol();
const y = Symbol();
```

**The typeof Operator** [S1]
You can use the `typeof` operator to find the type of a JavaScript variable. The `typeof` operator returns the type of a variable or an expression.
```javascript
typeof ""             // Returns "string"
typeof "John"         // Returns "string"
typeof "John Doe"     // Returns "string"
```
```javascript
typeof 0              // Returns "number"
typeof 314            // Returns "number"
typeof 3.14           // Returns "number"
typeof (3)            // Returns "number"
typeof (3 + 4)        // Returns "number"
```

**JavaScript Strings** [S1]
A string (a text string) is a series of characters like "John Doe". Strings are written with quotes — single or double:
```javascript
// Using double quotes:
let carName1 = "Volvo XC60";

// Using single quotes:
let carName2 = 'Volvo XC60';
```
You can use quotes inside a string, as long as they don't match the quotes surrounding the string:
```javascript
// Single quote inside double quotes:
let answer1 = "It's alright";

// Single quotes inside double quotes:
let answer2 = "He is called 'Johnny'";

// Double quotes inside single quotes:
let answer3 = 'He is called "Johnny"';
```

**JavaScript Numbers** [S1]
All JavaScript numbers are stored as decimal numbers (floating point). Numbers can be written with or without decimals:
```javascript
// With decimals:
let x1 = 34.00;

// Without decimals:
let x2 = 34;
```

**Exponential Notation** [S1]
Extra large or extra small numbers can be written with scientific (exponential) notation:
```javascript
let y = 123e5;    // 12300000
let z = 123e-5;   // 0.00123
```

**JavaScript Booleans** [S1]
JavaScript booleans can only have one of two values: `true` or `false`. The boolean value of an expression is the basis for JavaScript comparisons. All JavaScript comparison operators (like `==`, `!=`, `<`, `>`) return `true` or `false` from the comparison:
```javascript
let x = 5;

(x == 8); // equals false
(x != 8); // equals true
```

| Description | Expression | Returns |
|-------------|------------|---------|
| Equal to | (x == 8) | false |
| Not equal to | (x != 8) | true |
| Greater than | (x > 8) | false |
| Less than | (x < 8) | true |

**Datatype undefined** [S1]
In computer programs, variables are often declared without a value. A variable without a value has the datatype `undefined`:
```javascript
let carName;
```

**Empty Values** [S1]
An empty value has nothing to do with `undefined`. An empty string has both a legal value and a type:
```javascript
let car = "";    // The value is "", the typeof is "string"
```

## 🛠️ 적용 사례 (Applied in summary)
The page's own snippets are the canonical applied examples — declaring values of each of the 8 types, probing them with `typeof`, and distinguishing `undefined` from the empty string. No external project/commit applications found in the source.

## 💻 코드 패턴 (Code patterns)
Find a variable's type:
```javascript
typeof (3 + 4)        // Returns "number"
```
Nest quotes inside a string:
```javascript
let answer1 = "It's alright";
let answer3 = 'He is called "Johnny"';
```
Write numbers in exponential notation:
```javascript
let y = 123e5;    // 12300000
let z = 123e-5;   // 0.00123
```

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
No contradictions found in the source. Note that the source reuses the variable name `x`/`y` across separate per-type example blocks; each block is illustrative and not meant to run as one script.

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

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[JavaScript Tutorial]]
- **관련 개념:** [[JavaScript Introduction]], [[JavaScript Operators]], [[JavaScript Comparisons]], [[JavaScript Assignment]]
- **참조 맥락:** Referenced whenever reasoning about what a variable holds and how `typeof` or comparisons behave on it.

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

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