05. JavaScript Coomparisons

Javascript Comparisons

comparision operators
how to use comparisons
logical operators
conditional operators

comparisions and logical operators are used to test for true or false

Comparision operators

Comparision operators are used in logical statements to determine equality or difference between variables or values

Operator Description
= = is equal to value... is equal to value
= = = is exactly eual to value and type
!= is not equal
> is grater than
< is less than
>= is greater than or equal to 
<= is less than or equal to

How to use comparisions

Comparision operators can be used in conditional statements to compare values and taje action depending on the result.

if(age<18)

document.write("Too Young");

Logical Operators

Logical operators are used to determine the logic between variables or values

Operators Description
&& and
|| or
! not

Conditional Operator

Javascript also contains a conditional operator that assigns a value to a variable based on some conditions.

variablename=(condition)?value1:value2

ex:

greeting=(visitor=="Pres")?Dear President ":"Dear";

If the variable visitor has the value of "Pres", then the variable greeting will be assigned the value "daer president" else it will be assigned "dear"


No comments:

My Favorite Books

  • C and Data Structures by Ashok N. kamthane
  • Web Technologies by A. A. Puntambekar
  • Learn HTML and CSS with W3Schools
  • Learn JavaScript and Ajax with W3Schools
  • HTML5 Black Book: Covers Css3, Javascript,XML, XHTML, Ajax, PHP And Jquery
  • HTML5 Application Development Fundamentals: MTA Exam 98-375
  • .NET 4.0 Programming 6-In-1, Black Book
  • SQL Server 2008 R2 Black Book
  • Asp.net 4.0 Projects Covers: net 3.5 And .net 4.0 Codes, Black Book
  • UNIX Shell Programming 1 Edition by Yashavant Kanetkar
  • UNIX and Shell Programming 1 Edition by Richard F. Gilberg, Behrouz A. Forouzan
  • Computer Networks by Andrew S. Tanenbaum
  • Multiple Choice questions in computer science by Timothy J Williams