Angular Certification Training
- 16k Enrolled Learners
- Weekend
- Live Class
An operator is used for manipulating a certain value or operand. Operators are used to perform specific mathematical and logical computations on operands. In this article, we will discuss about different JavaScript Operators and how they are used in a code in the following sequence:
Operators are used for comparing values, perform arithmetic operations, etc. For example, if we take a simple expression, 4 + 5 is equal to 9. Here 4 and 5 are called operands and ‘+’ is called the operator. JavaScript consists of different types of operators that are used to perform different operations.
There are different types of operators in JavaScript that are used for performing different operations. Some of the JavaScript Operators include:
Arithmetic operators are used to perform arithmetic operations on the operands. Here is a list of operators that are known as JavaScript arithmetic operators:
Operator | Description | Example |
+ | Adds two operands | 10 + 20 = 30 |
– | Subtracts the second operand from the first | 30 – 20 = 10 |
/ | Divide the numerator by the denominator | 20/10 = 2 |
* | Multiply two operands | 5 * 5 = 25 |
% | Outputs the remainder of an integer division | 20 % 10 = 0 |
++ | Increases an integer value by one | |
— | Decreases an integer value by one | var a=20; a–; Now a = 19 |
The JavaScript comparison operator compares the two operands. The comparison operators are as follows:
The bitwise operators are used to perform bitwise operations on operands. Here is a list of bitwise operators:
The list provides all the JavaScript logical operators:
The Assignment operators are used to assign values to the operand. The following operators are known as JavaScript assignment operators:
Operator | Description | Example |
= | Assigns values from the right side operand to the left side operand | 20+10 = 30 |
+= | It adds the right operand to the left operand and assigns the result to the left operand | var a=20; a+=10; Now a = 30 |
-= | It subtracts the right operand from the left operand and assigns the result to the left operand | var a=30; a-=10; Now a = 20 |
*= | It multiplies the right operand with the left operand and assigns the result to the left operand | var a=10; a*=20; Now a = 200 |
/= | It divides the left operand with the right operand and assigns the result to the left operand | var a=10; a/=2; Now a = 5 |
%= | It takes modulus using two operands and assigns the result to the left operand | var a=10; a%=2; Now a = 0 |
These were some of the common JavaScript operators with their definition and example. With this, we have come to the end of our article.
Now that you know about JavaScript Operators, check out the Web Development Certification Training by Edureka. Web Development Certification Training will help you Learn how to create impressive websites using HTML5, CSS3, Twitter Bootstrap 3, jQuery and Google APIs and deploy it to Amazon Simple Storage Service(S3).
Got a question for us? Please mention it in the comments section of “JavaScript Operator” and we will get back to you.