JavaScript: Logic and Comparison Operators

Posted by ActiveEnnovations

JavaScript: Logic and Comparison Operators

            We all should remember the less than (< ) and greater than (>) from math classes back in school. Logical operators extended more into philosophy classes. The use of these symbols is widely used for comparisons and logical operations in numerous programming languages. The usage is not too much different that what it was back in our classes. The comparison symbols are used to indicate whether a value is less than, greater than, or equal to another value, while logical operators compare conditions to check if a  resulting condition is true or false.

The comparison operators:

“==” – A pair of sequential equal signs become the “Is Equal To” comparison

“===”-Three equal signs in a row becomes the “Is Exactly Equal To” comparison

“!=” – An exclamation point followed by an equal sign represents “Not Equal To”

“>” – An opening to the left still stands for “Greater Than”

“<” – An opening to the right still means “Less Than”

“>=”—Greater than or equal to

“<=”—Less than or equal to.

 

The logical operators:

“&&”- Two consecutive Ampersands represent a logical  “AND”.  Will compare two or more conditions and will return “true”, if all of the conditions are true. Otherwise the result is false.

“||”—Two consecutive pipes represents a logical “Or”. The result will be true if one or both of the compared conditions is true. It will only return “false” if both conditions are false

“!”—The Exclamation point is used to symbolize “Not”. Placing this in front of an expression will return the opposite of the resulting value.

Examples:

 Let A=True,  B=True, C=False

A && B = True          A || B= True    A && C = False    A || C=True     !A=False

 

Posted on: 7/20/2010 at 2:14 PM
Tags: , ,
Categories: JavaScript
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (8) | Post RSSRSS comment feed

Comments

ugg boots wholesale People's Republic of China

Wednesday, October 20, 2010 7:53 AM

ugg boots wholesale

This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information

ugg Elsey Boots People's Republic of China

Friday, October 22, 2010 9:18 AM

ugg Elsey Boots

This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information

pierscionki United States

Saturday, October 23, 2010 8:59 AM

pierscionki

Great article I've just added to my bookmark list.

short sale help United States

Tuesday, October 26, 2010 1:11 PM

short sale help

Can you message me with any tips about how you made this website look this awesome , I would appreciate it!

Anti Wrinkle Injections United States

Tuesday, October 26, 2010 1:30 PM

Anti Wrinkle Injections

I'm getting a browser error, is anyone else?

sponser a child United States

Tuesday, October 26, 2010 11:08 PM

sponser a child

Have you considered adding some videos to your article? I think it will really enhance my understanding.

Samsung Mobile Phone Insurance United States

Monday, November 22, 2010 7:32 PM

Samsung Mobile Phone Insurance

This really answered my problem, thank you!

3GS iPhone Insurance United States

Monday, November 22, 2010 7:36 PM

3GS iPhone Insurance

I'm getting a javascript error, is anyone else?

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading