Skip to content

JavaScript operators list

  • by

The JavaScript operators list includes a comprehensive set of operators used for performing various operations in JavaScript. Here is a list of commonly used operators in JavaScript:

  1. Arithmetic Operators:
    • Addition (+)
    • Subtraction (-)
    • Multiplication (*)
    • Division (/)
    • Remainder/Modulus (%)
    • Exponentiation (**)
  2. Assignment Operators:
    • Assignment (=)
    • Addition assignment (+=)
    • Subtraction assignment (-=)
    • Multiplication assignment (*=)
    • Division assignment (/=)
    • Remainder/Modulus assignment (%=)
  3. Comparison Operators:
    • Equal to (==)
    • Not equal to (!=)
    • Strict equal to (===)
    • Strict not equal to (!==)
    • Greater than (>)
    • Less than (<)
    • Greater than or equal to (>=)
    • Less than or equal to (<=)
  4. Logical Operators:
    • Logical AND (&&)
    • Logical OR (||)
    • Logical NOT (!)
  5. Bitwise Operators:
    • Bitwise AND (&)
    • Bitwise OR (|)
    • Bitwise XOR (^)
    • Bitwise NOT (~)
    • Left shift (<<)
    • Right shift (>>)
    • Unsigned right shift (>>>)
  6. Increment/Decrement Operators:
    • Increment (++)
    • Decrement (–)
  7. Ternary/Conditional Operator:
    • Ternary operator (condition ? expr1: expr2)
  8. String Operator:
    • Concatenation (+)

These are some of the most commonly used operators in JavaScript. Keep in mind that there are additional operators and variations available for specific use cases.

JavaScript operators list example

Simple example code of JavaScript operators in action:

Arithmetic Operators:

let x = 5;
let y = 3;

let sum = x + y; // 8
let difference = x - y; // 2
let product = x * y; // 15
let quotient = x / y; // 1.6666666666666667
let remainder = x % y; // 2
let exponentiation = x ** y; // 125

Assignment Operators:

let x = 10;

x += 5; // x is now 15 (equivalent to x = x + 5)
x -= 3; // x is now 12 (equivalent to x = x - 3)
x *= 2; // x is now 24 (equivalent to x = x * 2)
x /= 4; // x is now 6 (equivalent to x = x / 4)
x %= 2; // x is now 0 (equivalent to x = x % 2)

Comparison Operators:

let x = 5;
let y = 3;

console.log(x == y); // false (equal to)
console.log(x != y); // true (not equal to)
console.log(x === y); // false (strict equal to)
console.log(x !== y); // true (strict not equal to)
console.log(x > y); // true (greater than)
console.log(x < y); // false (less than)
console.log(x >= y); // true (greater than or equal to)
console.log(x <= y); // false (less than or equal to)

Logical Operators:

let x = 5;
let y = 3;

console.log(x > 0 && y > 0); // true (logical AND)
console.log(x > 0 || y > 0); // true (logical OR)
console.log(!(x > 0)); // false (logical NOT)

Increment/Decrement Operators:

let x = 5;

x++; // x is now 6 (post-increment)
++x; // x is now 7 (pre-increment)
x--; // x is now 6 (post-decrement)
--x; // x is now 5 (pre-decrement)

Ternary/Conditional Operator:

let age = 18;
let message = (age >= 18) ? "You are an adult" : "You are not an adult";
console.log(message); // "You are an adult"

String Operator:

let firstName = "John";
let lastName = "Doe";
let fullName = firstName + " " + lastName;
console.log(fullName); // "John Doe"

Comment if you have any doubts or suggestions on this Js Operator topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading