NOT Equal to (!=) (Operator/equality)

Compare two operands for inequality.


ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server version - 2.0
Opera - 3.0
Property/method value type:Boolean primitive
JavaScript syntax:-anOperand1 != anOperand2
Argument list:anOperand1A value to be compared
anOperand2Another value to be compared

The two operands are compared, and the Boolean true value is returned if they are not equal, otherwise false if they are equal. Note that JavaScript will attempt to convert both operands to the same type for comparison.

When testing for inequality, the following rule is invariant:

A != B

is equivalent to:

!(A == B)

Also, the rule of positioning allows that:

A == B

is identical to:

B == A

(Apart from the fact that exchanging the operands in this way alters the order in which they are evaluated.)

Exchanging the operands may have undesirable side effects if they are expressions. For example, they may call functions and test the results. If the functions are not totally independent of one another, you may get unexpected results.

The associativity is from left to right.

Refer to the Operator Precedence topic for details of execution order.

Refer to the Equality expression topic for a discussion on the ECMA standard definition of the equality testing rules.

See also:ASCII, Associativity, Equal to (==), Equality expression, Equality operator, Greater than (>), Greater than or equal to (>=), Identically equal to (===), Less than (<), Less than or equal to (<=), Logical expression, Logical NOT - complement (!), Logical operator, NOT Identically equal to (!==), Operator Precedence, Relational expression, Relational operator, typeof, Unicode


ECMA 262 edition 2 - section - 11.9.2

ECMA 262 edition 2 - section - 11.9.3

ECMA 262 edition 3 - section - 11.9.2

ECMA 262 edition 3 - section - 11.9.3