Skip to content

Operator

In one line

An operator is a symbol that performs an operation on one or more values, like + for addition or === for comparison.

In simple words

An operator is a symbol or keyword that tells the computer to perform a specific operation on values (called operands). You use operators constantly: + adds numbers, === compares values, && combines booleans, = 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.

Example

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)

Each operator performs a different operation: + adds, > compares, % gives remainder, = assigns.

Common confusions

  • Confused with: function

    The difference: Operators are symbols with special syntax (a + b); functions are named and called with parentheses (add(a, b)). Operators are built into the language; functions are user-defined (mostly).

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary