Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Scripting
 Comparison Operators
Collapse All/Expand All Collapse All
This page is specific to
.NET Framework 3.0

Other versions are also available for the following:
JScript
Comparison Operators (Windows Scripting - JScript)

Returns a Boolean value indicating the result of the comparison.

expression1 comparisonoperator expression2
expression1

Any expression.

comparisonoperator

Any comparison operator.

expression2

Any expression.

When comparing strings, JScript uses the Unicode character value of the string expression.

The following describes how the different groups of operators behave depending on the types and values of expression1 and expression2:

Relational (<, >, <=, >=)

  • Attempt to convert both expression1 and expression2 into numbers.

  • If both expressions are strings, do a lexicographical string comparison.

  • If either expression is NaN, return false.

  • Negative zero equals Positive zero.

  • Negative Infinity is less than everything including itself.

  • Positive Infinity is greater than everything including itself.

Equality (==, !=)

  • If the types of the two expressions are different, attempt to convert them to string, number, or Boolean.

  • NaN is not equal to anything including itself.

  • Negative zero equals positive zero.

  • null equals both null and undefined.

  • Values are considered equal if they are identical strings, numerically equivalent numbers, the same object, identical Boolean values, or (if different types) they can be coerced into one of these situations.

  • Every other comparison is considered unequal.

Identity (===, !==)

These operators behave identically to the equality operators except no type conversion is done, and the types must be the same to be considered equal.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker