Results 1 to 6 of 6

Thread: How to use Comparison and Logical Operators in JavaScript?

  1. #1
    Join Date
    Aug 2006
    Posts
    221

    How to use Comparison and Logical Operators in JavaScript?

    I have recently turned towards the JavaScript. I knew many comparison and logical operators (not all), but I don't know how to use that operators. I want to compare and use some logic in my program, so I want that operators to be used in my program. So please tell me how to use Comparison and Logical Operators in JavaScript.?? Since I don't know the all operators, please provide me same.
    AMD Sempron 2800+ @ 2Ghz
    Asus A7V8X-LA
    120Gb Seagate barracuda 7200Rpm Ultra-ATA 100
    Elixir 512mb DDR Pc3200 (Soon 1Gb)
    Club 3D Radeon 9600 256Mb
    Lite-On Cd & Dvd writer combo
    IDE-Dvd drive
    400w Psu
    Windows Xp Pro Sp2
    Advent Wireless Mouse & Keyboard.

  2. #2
    Join Date
    Aug 2006
    Posts
    235

    Re: How to use Comparison and Logical Operators in JavaScript?

    If your program want to do some comparing or want to perform some logical operations, you can use the Comparison and Logical Operators. The Comparison and Logical operators are used to test for true or false. Also the The Conditional Operator is handy for quickly assigning a different value to a variable depending on the outcome of a condition. Comparison operators are used in logical statements to determine equality or difference between variables or values. Whereas the logical operators are used to determine the logic between variables or values.
    3.2 (northwood)
    2gig ram
    ATI AIW X800xt 256mb
    Gigabyte GA-8knxp 875p Chipset
    Optiwrite 8X DVD Burner
    Win XP PRO Sp2 (Works Perfectly)
    2 SATA Raptor 74gig Raid 0
    2 7200 IDE 320gig HD

  3. #3
    Join Date
    Jul 2006
    Posts
    289

    Re: How to use Comparison and Logical Operators in JavaScript?

    The following is the list of the Comparison operator.
    1. == This operator is equal to and used to check whether, variable is equal to or not. It returns false, if the answer is negative.
    2. != This is not equal. Returns true, if it is correct.
    3. > Used to check whether the variable is greater than or not.
    4. < Used to check whether the variable is less than or not.
    5. >= This is greater than or equal to.
    6. <= This operator is less than or equal to.
    Signatures reduce available bandwidth

  4. #4
    Join Date
    Jul 2006
    Posts
    286

    Re: How to use Comparison and Logical Operators in JavaScript?

    You can use the Comparison operators for the conditions. You will have to keep in mind that the comparison operators can be used in conditional statements to compare values and take action depending on the result. Have a look at the example below :
    Code:
    if (age>50) document.write("You are old");
    If you enter the age more than 50, then it will display the message "You are old".
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

  5. #5
    Join Date
    Jul 2006
    Posts
    442

    Re: How to use Comparison and Logical Operators in JavaScript?

    You will have to use the Logical Operators if you want to do some logical working. The following are the Logical Operators :
    1. && (AND) - This operator is used to compare 2 expressions.
    2. || (OR) - This operator is used for doing the logical or conditions.
    3. ! (NOT) - This operator is used when you have to do some negative conditions.
    "When they give you ruled paper, write the other way..." J.R.J.

  6. #6
    Join Date
    Nov 2008
    Posts
    1,192

    Re: How to use Comparison and Logical Operators in JavaScript?

    You can also use the Conditional Operator in JavaScript which contains a conditional operator that assigns a value to a variable based on some condition. The Conditional Operator is handy for quickly assigning a different value to a variable depending on the outcome of a condition. The syntax for the conditional operating :
    Code:
    variablename=(condition)?value1:value2
    The following is the example for conditional operator :
    Code:
    greeting=(visitor=="PRIN")?"Respected Principal ":"Respected ";
    In the above example, if the variable visitor has the value of "PRIN", then the variable greeting will be assigned the value "Respected Principal " else it will be assigned "Respected".

Similar Threads

  1. What is a CPU thread / logical core is?
    By Laila in forum Motherboard Processor & RAM
    Replies: 4
    Last Post: 28-01-2011, 02:00 AM
  2. Logical drive disappeared
    By Chakrika in forum Hardware Peripherals
    Replies: 4
    Last Post: 25-01-2011, 02:06 PM
  3. What are the physical and logical format in XML?
    By Deward in forum Software Development
    Replies: 7
    Last Post: 31-10-2010, 04:47 AM
  4. Use of Bitwise Logical Operators : C
    By Gavyn in forum Software Development
    Replies: 4
    Last Post: 06-02-2010, 04:25 PM
  5. Bitwise logical operators in Java
    By beelow in forum Software Development
    Replies: 3
    Last Post: 20-11-2009, 01:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,965,590.31733 seconds with 17 queries