--- id: javascript-operators title: "JavaScript Operators" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["JS operators", "JavaScript operator types", "arithmetic operators", "assignment operators", "comparison operators", "logical operators", "concatenation operator"] 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", "operators"] raw_sources: ["https://www.w3schools.com/js/js_operators.asp"] applied_in: [] github_commit: "" --- # [[JavaScript Operators]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) JavaScript operators are used for mathematical and logical computations β€” the `=` assigns, `+` adds (and concatenates strings), `*` multiplies, and comparison/logical operators evaluate conditions. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Operators are for mathematical and logical computations** β€” they perform operations on values and variables. [S1] - **Four core single examples** β€” the assignment operator `=` assigns values, the addition operator `+` adds, the multiplication operator `*` multiplies, and the comparison operator `>` compares. [S1] - **Operator categories** β€” JavaScript operators include Arithmetic, Assignment, Comparison, Logical, and String operators. [S1] - **`+` is overloaded** β€” when used on strings, the `+` operator is called the concatenation operator; if you add a number and a string, the result is a string. [S1] - **Comparisons return booleans** β€” comparison operators always return `true` or `false`, and strings are compared alphabetically. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Compute into a new variable** β€” combine two operands with an arithmetic operator and store the result: `let z = x + y;`. [S1] - **Compound assignment** β€” `x += 5` is shorthand for `x = x + 5`. [S1] - **Concatenate then assign** β€” build a string with `+` and a separator: `text1 + " " + text2`. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **Operators are for Mathematical and Logical Computations** [S1] The assignment operator (`=`) assigns a value to a variable: ```javascript let x = 10; ``` The addition operator (`+`) adds values: ```javascript let x = 5; let y = 2; let z = x + y; ``` The multiplication operator (`*`) multiplies values: ```javascript let x = 5; let y = 2; let z = x * y; ``` A more complex expression mixing addition and multiplication: [S1] ```javascript let a = 3; let x = (100 + 50) * a; ``` **Types of JavaScript Operators** [S1] There are different types of JavaScript operators: Arithmetic, Assignment, Comparison, String, Logical, and others. **JavaScript Arithmetic Operators** [S1] Arithmetic operators are used to perform arithmetic on numbers: | Operator | Description | |----------|-------------| | + | Addition | | - | Subtraction | | * | Multiplication | | ** | Exponentiation | | / | Division | | % | Modulus (Division Remainder) | | ++ | Increment | | -- | Decrement | **JavaScript String Addition** [S1] When used on strings, the `+` operator is called the concatenation operator: ```javascript let text1 = "John"; let text2 = "Doe"; let text3 = text1 + " " + text2; ``` The `+=` assignment operator can also concatenate: ```javascript let text1 = "What a very "; text1 += "nice day"; ``` **Adding Strings and Numbers** [S1] If you add a number and a string, the result will be a string: ```javascript let x = 5 + 5; let y = "5" + 5; let z = "Hello" + 5; ``` **JavaScript Assignment Operators** [S1] Assignment operators assign values to JavaScript variables. For example, `x += 5` is the same as `x = x + 5`: ```javascript let x = 10; x += 5; ``` | Operator | Example | Same As | |----------|---------|---------| | = | x = y | x = y | | += | x += y | x = x + y | | -= | x -= y | x = x - y | | *= | x *= y | x = x * y | | /= | x /= y | x = x / y | | %= | x %= y | x = x % y | | **= | x **= y | x = x ** y | **JavaScript Comparison Operators** [S1] Comparison operators always return `true` or `false`: ```javascript let x = 5; let result = x > 8; ``` | Operator | Description | Example | |----------|-------------|---------| | == | equal to | x == 5 | | === | equal value and equal type | x === 5 | | != | not equal | x != 5 | | !== | not equal value or not equal type | x !== 5 | | > | greater than | x > 5 | | < | less than | x < 5 | | >= | greater than or equal to | x >= 5 | | <= | less than or equal to | x <= 5 | Strings are compared alphabetically: [S1] ```javascript let text1 = "A"; let text2 = "B"; let result = text1 < text2; ``` **JavaScript Logical Operators** [S1] | Operator | Description | |----------|-------------| | && | logical and | | \|\| | logical or | | ! | logical not | ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own snippets are the canonical applied examples β€” assigning with `=`, computing with `+`/`*`, concatenating strings, compound-assigning with `+=`, and comparing values/strings. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Compute and store a result: ```javascript let x = 5; let y = 2; let z = x + y; ``` Concatenate strings with a separator: ```javascript let text3 = text1 + " " + text2; ``` Compound assignment: ```javascript let x = 10; x += 5; ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. The behavior that `"5" + 5` yields a string (`"55"`) rather than `10` is intentional, not a contradiction β€” `+` concatenates when a string operand is present. ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.88 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[JavaScript Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[JavaScript Arithmetic]], [[JavaScript Assignment]], [[JavaScript Comparisons]], [[JavaScript Types]] - **μ°Έμ‘° λ§₯락:** The umbrella reference for the operator-family pages (arithmetic, assignment, comparison, logical) that follow it. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” JavaScript Operators β€” https://www.w3schools.com/js/js_operators.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).