Welcome to Home.

Wednesday, July 8, 2015

Operators in JavaScript

The operator itself  is a keyword or a symbol that does something to a value when used in expression. For example, the arithmetic operator(+) adds two values together. A symbol is used in an expression with either one or two values and performs a calculation on the values to generate a result. An expression is just like a mathematical expression. The value are known as operands. Operators that require only one operant(value) are sometimes refered to as a unary operators. While those that require two values are sometime called binary operators. The different types of operators that supports in JavaScript are:
1.       Arithemtic operator
2.       Assignment operator
3.       Comparison operator
4.       Logical operator
5.       String operator
1.Arithemtic operator: It performs arithemetic operations upon operants.
2.Assignment operator: The basic assignment operator is the equal (sign),but donot take this to mean that it checks whether two values are equal.
3.Comparison operator:It compare two operants and then return either true or not. The comparison for checking two operants are equal is two equal signs (A single equal sign would be an assignment operator)
Operator
Discription
==
Is equal to
!=
not equal to
> 
More than
< 
Less than
>=
More or equal to
<=
Less or equal to

4.Logical (Boolean) operator: Logic operator returns one of two values i.e., true or false. They are particularly helpful when  we want to evaluate more than one expression at a time.
Operator
Name
??
OR
!
NOT
&&
AND

The two operants in logical or Boolean operator evaluate to either true or false. For example: if x=1, y=2 is true and y is greater than 1. So,the above expression returns true because both of the operants evaluate to true.
5.String operation: We can also add texts to string using the plus operator.(For eg. Here + operator is being used to add two variables that are string together.)
Var first_word=”Hellow”;
Var last_word=”Saroj”;
Var SingleWord = first_word+last_word;

 This process is called Sting concatenation.

No comments:

Post a Comment