JavaScript Arithmetic Operators
JavaScript Arithmetic Operators perform arithmetic operations: addition (+), subtraction (-), multiplication (*), division (/), modulus (%), and exponentiation (**).
Name |
Description |
Syntax |
Example |
Addition ‘+’ operator performs addition on two operands. This ‘+’ operator can also be used to concatenate (add) strings. |
Y = “Geeks” + “for” + “Geeks” gives Y = “w3wiki” Y |
||
Subtraction ‘-‘ operator performs subtraction on two operands. |
Y = 5 – 3 gives Y = 2 |
||
Multiplication ‘*’ operator performs multiplication on two operands. |
Y = 5 * 5 gives Y = 25 |
||
Division ‘/’ operator performs division on two operands (divide the numerator by the denominator). |
Y = 5 / 5 gives Y = 1 |
||
Modulus ‘%’ operator gives a remainder of an integer division. |
A % B means remainder (A/B) Y = 5 % 4 gives Y = 1 |
||
Exponentiation ‘**’ operator give the power of the first operator raised to the second operator. |
Y = 5 ** 3 gives Y = 125 |
||
Increment ‘+ +’ operator increases an integer value by one. |
let A = 10 and Y = A + + then A = 11, Y=10 |
||
Decrement ‘- -‘ operator decreases an integer value by one. |
let A = 10 and Y = A – – then A = 9, Y=10 |
||
Unary ‘+’ is the fastest and preferred way of converting something into a number |
+a means a is a positive number |
||
Negation ‘-‘ operator gives the negation of an operand. |
-a means a is a negative number |
JavaScript Operators
JavaScript operators are symbols used to perform specific mathematical, comparison, assignment, and logical computations on operands. They are fundamental elements in JavaScript programming, allowing developers to manipulate data and control program flow efficiently. Understanding the different types of operators and how they work is important for writing effective and optimized JavaScript code.
JavaScript Operators: There are various operators supported by JavaScript.
Table of Content
- JavaScript Arithmetic Operators
- JavaScript Assignment Operators
- JavaScript Comparison Operators
- JavaScript Logical Operators
- JavaScript Bitwise Operators
- JavaScript Ternary Operators
- JavaScript Comma Operators
- JavaScript Unary Operators
- JavaScript Relational Operators
- JavaScript BigInt Operators
- JavaScript String Operators