--- id: javascript-primitive-data-types title: "JavaScript Primitive Data Types" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["JS primitives", "primitive types", "string number boolean", "undefined null", "BigInt"] 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", "primitives", "data-types", "string", "number"] raw_sources: ["https://www.w3schools.com/js/js_datatypes_primitives.asp"] applied_in: [] github_commit: "" --- # [[JavaScript Primitive Data Types]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) JavaScript has 7 primitive data types β€” Number, BigInt, String, Boolean, Undefined, Null, and Symbol β€” each a simple, immutable value distinct from the single object type. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **7 primitive types** β€” JavaScript variables can hold 7 primitive types (Number, BigInt, String, Boolean, Undefined, Null, Symbol) or 1 object type. [S1] - **Strings** β€” a string is a series of characters, written with single or double quotes. [S1] - **Numbers are 64-bit floats** β€” all JavaScript numbers are stored as double (64-bit floating point) values; they support decimals and exponential notation. [S1] - **BigInt (ES2020)** β€” handles integers too large for standard numbers. [S1] - **Undefined vs Null** β€” a variable without a value is `undefined`; `null` represents the intentional absence of a value, but `typeof null` returns `"object"` (a historical quirk). [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Nest opposite quotes** β€” put single quotes inside double-quoted strings (and vice versa) to avoid escaping. [S1] - **`===` vs `==` for null/undefined** β€” strict equality (`===`) is `true` only when value and type match; loose equality (`==`) treats `null` and `undefined` as equal. [S1] - **Empty string is still a string** β€” `let car = "";` has value `""` and `typeof "string"`. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) JavaScript variables can hold 8 types of data: 7 primitive types or 1 object type. The primitive types are: Number, BigInt, String, Boolean, Undefined, Null, and Symbol. [S1] **JavaScript Strings** A string is a series of characters like "John Doe", written with single or double quotes. [S1] ```javascript // Using double quotes: let carName1 = "Volvo XC60"; // Using single quotes: let carName2 = 'Volvo XC60'; ``` You can nest the opposite quote type inside a string: [S1] ```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** All JavaScript numbers are stored as decimal (floating point) values β€” always double (64-bit floating point). [S1] ```javascript // With decimals: let x1 = 34.00; // Without decimals: let x2 = 34; ``` Exponential notation: [S1] ```javascript let y = 123e5; // 12300000 let z = 123e-5; // 0.00123 ``` **JavaScript BigInt** BigInt (ES2020) handles integers too large for standard numbers: [S1] ```javascript let x = BigInt("123456789012345678901234567890"); ``` **JavaScript Booleans** Booleans can only hold `true` or `false`: [S1] ```javascript let x = 5; let y = 5; let z = 6; (x == y) // Returns true (x == z) // Returns false ``` **The `typeof` Operator** The `typeof` operator identifies a variable's type. [S1] ```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" ``` **Undefined** A variable without a value has the value `undefined` and the type `undefined`: [S1] ```javascript let car; // Value is undefined, type is undefined ``` ```javascript car = undefined; // Value is undefined, type is undefined ``` **Empty Values** An empty string has both a legal value and a type: [S1] ```javascript let car = ""; // The value is "", the typeof is "string" ``` **Datatype null** `null` represents "nothing" β€” the intentional absence of a value: [S1] ```javascript let carName = null; ``` Notes on `null`: the `typeof` operator returns `"object"` for `null` (a historical quirk); the strict equality operator `===` returns `true` only if both value and type match; the loose equality operator `==` returns `true` for both `null` and `undefined`. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own declarations (string quoting variants, number/exponent/BigInt literals, boolean comparisons, and the undefined/empty/null examples) are the canonical applied examples. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Nest opposite quotes (language: JavaScript): ```javascript let answer1 = "It's alright"; let answer3 = 'He is called "Johnny"'; ``` Exponential number notation: ```javascript let y = 123e5; // 12300000 let z = 123e-5; // 0.00123 ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) `typeof null` returns `"object"` even though `null` is a primitive value β€” the page flags this as a historical quirk. BigInt was introduced in ES2020. [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 Object Data Types]], [[JavaScript typeof]], [[JavaScript Symbols]] - **μ°Έμ‘° λ§₯락:** Referenced whenever declaring simple values or reasoning about equality and `typeof` results. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” JavaScript Primitive Data Types β€” https://www.w3schools.com/js/js_datatypes_primitives.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Primitive Data Types" page (Astra wiki-curation, P-Reinforce v3.1 format).