Programming Operators Explained – Symbols, Types and How They Work

Every time your code does math, compares two values, or makes a decision — it uses operators. Operators are the symbols that tell your program what to do with data. Plus signs, equals signs, greater than symbols — you have seen them all before. In coding, they work the same way as in everyday math, just with a few extra tricks.

Arithmetic, comparison, logical operators
Real code examples in JS & Python
Common mistakes & how to avoid them
Operators at a glance
+ Add
Subtract
=== Equal
&& AND
% Modulo
! NOT
🚀 Step 6 of 13 · Beginner · ⏱️ 10 min read
⚙️ Operators

What Are Operators in Programming?

An operator is a symbol that tells the computer to perform a specific action on one or more values. Each symbol has one job — and it does that job every single time.
+Adds values
>Compares values
&&Combines conditions
===Checks equality
%Finds remainder
🧮 Analogy

Real-Life Analogy — Calculator Buttons

Think of operators like buttons on a calculator. Your values sit on either side. The operator tells the computer what to do. The result gets stored in a variable.

🧮 How it works:
7
value
+
operator
3
value
=
10
result
let result = 7 + 3; // → 10
The values go on either side of the operator. The operator tells the computer what to do. Simple as that.
What are operators in programming infographic with examples
🧮

Arithmetic Operators — Doing Math

If you’ve used a calculator — you already know most of these.

These are the operators you use to do math in code. They work exactly like the math you learned in school — just written slightly differently.

➕ Basic Math

Basic Math Operators

+
Addition
5 + 3 = 8
Subtraction
5 – 3 = 2
*
Multiply
5 * 3 = 15
/
Division
10 / 4 = 2.5
**
Power
2 ** 3 = 8
% Modulo

The Modulo Operator — Finding Remainders

% gives you the remainder after division. Perfect for checking if a number is even or odd.

6 % 2
= 0
✅ Even number
7 % 2
= 1
❌ Odd number
10 % 3
= 1
1 left over
++ / — Shorthand

Increment and Decrement

++ adds 1. subtracts 1. Used constantly inside loops to count up or down.

➕ ++ Increment
let score = 10;
score++; // now 11
// same as score = score + 1
Adds 1 to the variable
➖ — Decrement
let lives = 3;
lives–; // now 2
// same as lives = lives – 1
Subtracts 1 from the variable
⚖️ Comparison

Comparison Operators — Comparing Values

Comparison operators compare two values and always return true or false. Nothing else. This makes them perfect for making decisions in your code.

📊 All Operators

All Comparison Operators Explained

===
Equal to
5 === 5
true
!==
Not equal to
5 !== 3
true
>
Greater than
5 > 3
true
<
Less than
5 < 3
false
>=
Greater or equal
5 >= 5
true
<=
Less or equal
3 <= 5
true
⚠️ Important

=== vs == — Why This Matters

== checks value only. === checks value AND type. This difference causes real bugs.

⚡ comparison.js
5 == “5” // true — ignores type!
❌ Avoid
5 === “5” // false — catches the difference
✅ Always Use
💡 Golden rule: Always use === — never ==. The triple equals checks both value and type, which prevents bugs that are very hard to find later.
🔗 Logical Operators

Logical Operators — Combining Conditions

Check multiple things in a single line.

Logical operators let you combine two or more conditions together. Instead of checking one thing at a time — you can check multiple things in a single line.
&&

AND Operator

Both must be true

Both conditions must be true for the result to be true. If even one is false — the whole thing is false.

🌍 Real life: You can enter a club if you are over 18 AND have a valid ID. Both must pass.
let canEnter = age >= 18 && hasID === true;
// both must be true — if either fails, result is false
true && truetrue
true && falsefalse
false && falsefalse
||

OR Operator

Just one must be true

Only one condition needs to be true. If at least one passes — the result is true.

🌍 Real life: You get a discount if you are a student OR a senior citizen. Just one is enough.
let hasDiscount = isStudent || isSenior;
// just one needs to be true — either works
true || falsetrue
false || falsefalse
true || truetrue
!

NOT Operator

Flips the result

Flips the result. Turns true into false, and false into true. Use it when you want to check if something is NOT the case.

🌍 Real life: Show the login button only if the user is NOT already logged in.
if (!isLoggedIn) {
  // show login button — user is NOT logged in
}
!truefalse
!falsetrue
✏️

Assignment Operators — Shorthand Writing

Store values faster with less code.

Assignment operators store values into variables. You already know the basic one — =. But there are shorter ways that save time and make your code cleaner.

= Basic

Basic Assignment

The = operator stores a value into a variable. It does not mean “equal to” — it means “store this value here.”

score
variable
=
10
value stored
⚡ assign.js
let score = 10; // store 10 in score
score = 20; // replace with 20
⚡ Shorthand

Shorthand Operators

Instead of writing score = score + 5, you can write score += 5. Same result — less typing.

score += 5 → same as → score = score + 5
score -= 3 → same as → score = score – 3
score *= 2 → same as → score = score * 2
score /= 4 → same as → score = score / 4
score %= 3 → same as → score = score % 3
💡 You will use += and -= the most. They are everywhere — especially inside loops when counting up or down.
⚡ Precedence

Operator Precedence — Which Runs First?

Code doesn’t always run left to right — it follows a specific order.

When you write an expression with multiple operators, the computer does not just run them left to right. It follows a specific order — just like BODMAS from math class.

📋 Order of Operations

Order of Operations in Code

1
( )
Parentheses
First
2
**
Powers
Second
3
* /
Multiply/Divide
Third
4
+ –
Add/Subtract
Last
10 + 5 * 2 // → 20 not 30 — * runs before +
⚠️ Beginners expect 30 — but * runs first → 10 + 10 = 20
(10 + 5) * 2 // → 30 — () forces + to run first
✅ Parentheses override everything — add first, then multiply
10 + 6 / 2 1 // → 12 — / first, then + and –
💡 Division runs first → 10 + 3 – 1 = 12
💡 Golden rule: When in doubt — use parentheses. They make your intention clear to both the computer and anyone reading your code.

FAQs About Operators

Quick answers to the questions beginners ask most

Q 01

What are the 4 basic operators in programming?

+
The 4 basic operators are Addition, Subtraction, Multiplication, and Division. They work exactly like math and are supported in every programming language.
+
Addition
5 + 3 = 8
Subtraction
5 – 3 = 2
*
Multiply
5 * 3 = 15
/
Division
10 / 2 = 5
These are called arithmetic operators. Master these first — everything else builds on them.
Q 02

What does % mean in coding?

+
% is the modulo operator. It gives you the remainder after division — not the result itself. Developers use it to check if numbers are even or odd, and to cycle through values in loops.
⚡ modulo.js
10 % 3 = 1 // 10 ÷ 3 = 3 remainder 1
6 % 2 = 0 // 0 remainder = even number
7 % 2 = 1 // 1 remainder = odd number
💡 Even or odd check: If number % 2 === 0 → even. If number % 2 === 1 → odd.
Q 03

What is the difference between = and == in coding?

+
They look similar but do completely different things. This is one of the most common beginner confusions in coding.
= Assignment — stores a value into a variable. let score = 10 Store Value
== Loose equality — checks value only, ignores type. 5 == "5" → true ❌ Avoid
=== Strict equality — checks value AND type. 5 === "5" → false ✅ Always Use
Rule: Use = to store. Use === to compare. Never use ==.
Still have questions? Browse our free tutorials.
Browse Tutorials →