Try my app Expense Manager @ google play and amazon store.

Wednesday, June 20, 2012

Java Script Tutorial 7 : Comparison and Logical Operators

Comparison operators are used in logical statements to determine equality or difference between variables or values. Comparison operators can be used in conditional statements to compare values and take action depending on the result. There are many Comparison operators used in javascript, some of these are below :


Operator Symbol Uses/Description
= = is equal to
= = = is exactly equal to (value and type both)
! = is not equal
> is greater than
< is less than
> = is greater than or equal to
< = is less than or equal to


Logical operators are used to determine the logic between variables or values. We can use following logical operators in java script.


&& ( and  )
|| ( or )
! ( not )


conditional operator : JavaScript contains conditional operator that assigns a value to a variable based on some condition. Syntax of this conditional operator is as below.


somevariablename = (put condition here) ? value1 : value2


If condition meets then output 'll be 'value1', and if condition doesn't meet then output 'll be 'value2'.

No comments:

Post a Comment

Follow by Email

Google+ Badge