Favorites

JavaScript == Equality 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 equality operator (==) checks whether two values are equal after converting them to a common type. The strict === operator is usually preferred.

Description

The equality operator == compares two values after type conversion. If the types differ, it converts them using a set of rules: strings and booleans become numbers, objects are converted to primitives, and null and undefined equal each other but nothing else. That leads to surprising results like 0 == '' and '1' == true both being true.

Because the rules are hard to remember, most code uses strict equality, ===, instead. One common, deliberate use of == is x == null, which checks for both null and undefined.

With objects, == compares references just like ===: two separate objects are never equal, even with the same contents. When comparing an object to a primitive, the object is converted with valueOf() or toString() first. NaN == NaN is false, as with strict equality. Linters such as ESLint's eqeqeq rule can enforce === throughout a project.

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(0 == '');
console.log(null == undefined, null == 0);
console.log([1] == 1);
let value;
console.log(value == 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