运算符
一句话解释
运算符是 symbol 那个执行操作 on one or 更多值, 如 + for addition or === for comparison.
用大白话说
运算符是 symbol or keyword 那个 tells computer 到执行特定操作 on 值 (called operands). 你 use 运算符 constantly: + 添加数字, === compares 值, && 组合布尔值, = assigns values.
Operators are categorized by what they do:
- Arithmetic:
+,-,*,/,%(math) - Comparison:
===,>,<,>=,<=(true/false) - Logical:
&&(AND),||(OR),!(NOT) - Assignment:
=,+=,-=(set values) - String:
+(concatenation when used with strings)
Operator precedence determines the order of evaluation (like PEMDAS in math): * binds tighter than +, so 2 + 3 * 4 is 14, not 20. Use parentheses to override precedence.
示例
javascript
let a = 10;
let b = 3;
console.log(a + b); // 13 (arithmetic)
console.log(a > b); // true (comparison)
console.log(a % b); // 1 (modulo/remainder)
console.log(a = 5); // 5 (assignment)每个运算符执行不同操作: + 添加, > compares, % gives remainder, = assigns.
常见混淆
容易混淆的对象: 函数
关键区别: 运算符是 symbols 使用特殊语法 (+ b); 函数是 named and called 使用 parentheses (添加(, b)). 运算符是 构建到 language; 函数是 用户-定义 (mostly).
相关术语
相关资源
相关课程
- 数字 and Math
学习关于运算符 and math.
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。