DEV Community

Mohamed Ajmal
Mohamed Ajmal

Posted on

Operators in JS

An operator in JavaScript is a symbol that performs an operation on values or variables. Operators are symbols that tell JavaScript what action to perform.

operator is a special symbol used to perform operations like addition, comparison, assignment, logic, etc...

Types of operators:

Arithmetic - +, -, , /, %, *
Comparison - ==, >, <, ===
Logical - &&, `
Assignment - =, +=, -=
Ternary - condition ? value1 : value2
String - +
Type - typeof, instanceof

Arithmetic operator: Arithmetic operators in JavaScript are used to perform basic math operations like addition, subtraction, multiplication, etc...

Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value.

Example : let a = 10;
let b = 3;

console.log(a + b); // 13
console.log(a - b); // 7
console.log(a * b); // 30
console.log(a / b); // 3.333...
console.log(a % b); // 1
console.log(a ** b); // 1000 (10³)

Ref : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators

Top comments (0)