Wednesday, February 29, 2012

Day 2 : JavaScript Operators and Variables


In computer programming, an operator is a character that represents an action, as for example a symbol * (star sign) is an arithmetic operator that represents multiplication, a plus sign (+) is an operator that represents the addition. In computer programs, one of the most familiar sets of operators is Boolean operators. It is used to work with true/false values. Boolean operators can include AND, OR & NOT in expression. Among the other types of operators used in computer programming are: Assignment Operators, which assign a specified value to another value and Relational Operators, which compare two values.

JavaScript operators, as like other operator in computer programming languages are used to perform an operation. There are different types of operators for different uses (operations).

Below is a listing of JavaScript operators with description of them.

Arithmetic Operators

Operator

Description
+
Addition
-
Subtraction
*
Multiplication
/
Division
%
Modulus (Remainder of a Division)
++
Increment
--
Decrement

Assignment Operators

Operator

Description
=
Assign
+=
Add and assign. For example, x+=y is the same as x=x+y.
-=
Subtract and assign. For example, x-=y is the same as x=x-y.
*=
Multiply and assign. For example, x*=y is the same as x=x*y.
/=
Divide and assign. For example, x/=y is the same as x=x/y.
%=
Modulus and assign. For example, x%=y is the same as x=x%y.

 

 Comparison Operators

Operator

Description
==
Is equal to
===
Is identical (is equal to and is of the same type)
!=
Is not equal to
!==
Is not identical
>
Greater than
>=
Greater than or equal to
<
Less than
<=
Less than or equal to

Logical/Boolean Operators

Operator

Description
&&
And
||
Or
!
Not

String Operators

In JavaScript, a string is simply a piece of text.
Operator

Description
=
Assignment
+
Concatenate (join two strings together)
+=
Concatenate and assign
Here in Day-2 section, you will get practice examples of JavaScript Operators, which will clear your practical concept.