1.
Post & Pre Increment/Decrement Operators
These operators are used to increase (++) or decrease (--) the value of a variable by 1. The
difference between pre and post is when the increment/decrement happens.
Pre-increment / Pre-decrement
++x → increments x before using it.
--x → decrements x before using it.
Example:
let x = 5;
let y = ++x; // pre-increment: x becomes 6, then assigned to y
[Link](x); // 6
[Link](y); // 6
Post-increment / post-decrement
x++ → increments x after using it.
x-- → decrements x after using it.
Example:
let x = 5;
let y = x++; // post-increment: y gets 5, then x becomes 6
[Link](x); // 6
[Link](y); // 5
2. Assignment Operators
Assignment operators are used to assign values to variables. The most basic is =, but there are
shorthand operators combining arithmetic with assignment:
Operator Meaning
= Assign
+= Add and assign
-= Subtract and assign
*= Multiply and assign
/= Divide and assign
%= Modulus and assign
Example:
let x = 10;
x += 5; // equivalent to x = x + 5
[Link](x); // 15
x *= 2; // equivalent to x = x * 2
[Link](x); // 30
3. Logical Operators
Logical operators are used to combine or invert boolean values.
Operator Symbol Description
AND && True if both operands are true
OR `
NOT ! Inverts the boolean value
Example:
let a = true;
let b = false;
[Link](a && b); // false
[Link](a || b); // true
[Link](!a); // false
4. Concatenate & Template String
String Concatenation
Combining strings using + operator.
let firstName = "Jeeva";
let lastName = "Vaishnavi";
let fullName = firstName + " " + lastName;
[Link](fullName); // Jeeva Vaishnavi
Template String (Template Literal)
Uses backticks `.
Supports variable interpolation with ${variable}.
Can span multiple lines easily.
let age = 20;
let message = `Hello ${firstName}, you are ${age} years old.`;
[Link](message);
// Hello Jeeva, you are 20 years old.
let multiLine = `This is line 1
This is line 2`;
[Link](multiLine);
5. Type Conversion
Converting one data type to another.
String to Number
let str = "123";
let num = Number(str);
[Link](num); // 123
[Link](typeof num); // number
Number to String
let x = 456;
let strX = String(x);
[Link](strX); // "456"
[Link](typeof strX); // string
Boolean Conversion
let val = 0;
[Link](Boolean(val)); // false
let val2 = "hello";
[Link](Boolean(val2)); // true
Automatic (Type Coercion)
JavaScript sometimes converts types automatically:
[Link]("5" - 2); // 3 (string converted to number)
[Link]("5" + 2); // "52" (number converted to string)