--- id: javascript-syntax title: "JavaScript Syntax" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["JS syntax", "literals", "identifiers", "case sensitivity", "camelCase"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.88 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["javascript", "js", "web", "frontend", "w3schools", "syntax", "identifiers"] raw_sources: ["https://www.w3schools.com/js/js_syntax.asp"] applied_in: [] github_commit: "" --- # [[JavaScript Syntax]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) JavaScript syntax is the set of rules for how programs are constructed β€” built from values (literals and variables), keywords, operators, expressions, and identifiers, all of which are case-sensitive. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Syntax = construction rules** β€” JavaScript syntax is the set of rules for how JavaScript programs are constructed. [S1] - **Two kinds of values** β€” fixed values (literals) and variable values (variables). [S1] - **Literals** β€” numbers are written with or without decimals; strings are text written within double or single quotes. [S1] - **Keywords create variables** β€” the `let` and `const` keywords are used to create variables; keywords are case-sensitive. [S1] - **Variables store data** β€” variables are containers for storing data values and must have unique names. [S1] - **JavaScript is case-sensitive** β€” `lastName` and `lastname` are two different variables. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Declare β†’ assign β†’ compute** β€” declare variables with `let`/`const`, assign values, then combine them in expressions. [S1] - **Lower camelCase naming** β€” hyphens are not allowed; underscores and PascalCase are possible, but JavaScript programmers tend to use lower camelCase. [S1] - **Identifier rules** β€” start with a letter, `_`, or `$`; later characters may include digits; never a reserved keyword; case-sensitive. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **JavaScript Syntax** β€” JavaScript syntax is the rules for how JavaScript programs are constructed. A basic program declares variables, computes values, and may contain comments: [S1] ```javascript // How to Declare variables: let x = 5; let y = 6; // How to Compute values: let z = x + y; // I am a Comment. I do Nothing ``` **JavaScript Values** β€” The JavaScript syntax defines two types of values: fixed values (literals) and variable values (variables). [S1] **JavaScript Literals** β€” Numbers are written with or without decimals: [S1] ```javascript 10.50 1001 ``` Strings are text, written within double or single quotes: [S1] ```javascript "John Doe" 'John Doe' ``` **JavaScript Keywords** β€” JavaScript keywords are used to identify actions to be performed. The `let` and `const` keywords tell the browser to create variables: [S1] ```javascript let x = 5; const fname = "John"; ``` **JavaScript Variables** β€” In a programming language, variables are used to store data values. JavaScript uses the keywords `var`, `let`, and `const` to declare variables. An equal sign (`=`) is used to assign values to variables: [S1] ```javascript // Define x as a variable let x; // Assign the value 6 to x x = 6; ``` **JavaScript Operators** β€” JavaScript uses arithmetic operators (`+`, `-`, `*`, `/`) to compute values, and an assignment operator (`=`) to assign values to variables: [S1] ```javascript let x = 5; let y = 6; let sum = x + y; ``` **JavaScript Expressions** β€” An expression is a combination of values, variables, and operators which computes to a value. The computation is called an evaluation. Expressions can also contain variable values, and the values can be of various types, such as numbers and strings: [S1] ```javascript 5 * 10 ``` ```javascript (5 + 6) * 10 ``` ```javascript x * 10 ``` ```javascript "John" + " " + "Doe" ``` **JavaScript Identifiers / Names** β€” Identifiers are JavaScript names, used to name variables, keywords, and functions. The rules for legal names are: [S1] - Names can contain letters, digits, underscores, and dollar signs. - Names must begin with a letter, `$`, or `_`. - Names are case-sensitive. - Reserved words (like JavaScript keywords) cannot be used as names. **JavaScript is Case Sensitive** β€” All JavaScript identifiers are case-sensitive. The variables `lastName` and `lastname` are two different variables: [S1] ```javascript let lastName = "Doe"; let lastname = "Peterson"; ``` **JavaScript and Camel Case** β€” Historically, programmers have used different ways of joining multiple words into one variable name: hyphens (not allowed in JavaScript β€” they are reserved for subtractions), underscores, Upper Camel Case (Pascal Case), and Lower Camel Case. JavaScript programmers tend to use camel case that starts with a lowercase letter. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own snippets are the canonical applied examples β€” declaring with `let`/`const`, computing `x + y`, evaluating expressions like `(5 + 6) * 10`, and the case-sensitive `lastName`/`lastname` pair. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Declare, assign, compute: ```javascript let x = 5; let y = 6; let z = x + y; ``` String concatenation expression: ```javascript "John" + " " + "Doe" ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) For joining multiple words into one identifier, the source presents the options and JavaScript's convention: [S1] | Style | Example | JavaScript stance | |-------|---------|-------------------| | Hyphens | `first-name` | Not allowed (reserved for subtraction) | | Underscores | `first_name` | Possible | | Upper Camel Case (Pascal) | `FirstName` | Possible | | Lower Camel Case | `firstName` | Preferred convention by JavaScript programmers | ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.88 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[JavaScript Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[JavaScript Statements]], [[JavaScript Variables]], [[JavaScript Comments]] - **μ°Έμ‘° λ§₯락:** The grammar layer underpinning every other JavaScript topic. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” JavaScript Syntax β€” https://www.w3schools.com/js/js_syntax.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Syntax" page (Astra wiki-curation, P-Reinforce v3.1 format).