Favorites

JavaScript != Inequality Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
!=
JavaScript Comparison OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

The loose inequality operator (!=) checks whether two values are not equal, converting types first. !== is usually preferred.

Description

The inequality operator != returns true if the operands are not equal after type conversion. It's the negation of == and has the same surprises, so !== is normally the better choice.

It converts types using the same rules as ==: strings and booleans become numbers, objects become primitives, and null and undefined are equal only to each other. That means '0' != false is false, which surprises many people.

The one common, deliberate use is value != null, which is true for anything except null and undefined in a single check. Elsewhere, prefer !==, which compares without converting types.

Properties

Operator
!=
Category
Comparison
Precedence
8 (1 is lowest, 18 is highest)
Associativity
left-to-right

Syntax

x != y

Example

console.log(1 != '1');
console.log(1 !== '1');
console.log(undefined != null);

Browser Support

The following information will show you the current browser support for the != operator. Hover over a browser icon to see the version that first introduced support for this operator.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee