Comparison operators in JS

  • == operator
  • === operator
  • Object.is()

== or Abstract equality operator

Cheat Sheet for you while using == operator

  • NaN is not equal to anything including itself
  • -0 equals 0
  • null equals both null & undefined
  • The expressions are either converted to a string, boolean, or number.
  • String comparison is case sensitive
  • If the two operands refer to the same object then it evaluates to true otherwise false
  • Always remember 6 falsy values (null, undefined, ‘’,0, NaN, and false)

=== or Strict equality operator

Cheat Sheet for you while using === operator

  • -0 equals 0
  • null only equals null
  • String comparison is case sensitive
  • NaN is not equal to anything including itself
  • If the two operands refer to the same object then it evaluates to true otherwise it returns false

Object.is()

--

--

--

Developer with 3 yrs of industrial experience in developing scalable web applications.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Using Bootstrap and Element UI Table with Vue.js / Nuxt.js

JavaScript Basics: How to create private & public functions in JavaScript with the Module Pattern

Let’s Build a Web App! Week 5 out of 30

Prevent “Cannot read property ‘…’ of undefined” errors with JavaScript Classes + TypeScript

Workaround made Solana Minting NFT Candy Machine V2.

Object.freeze vs Object.seal

Solidity gotchas — Part 1: Maps and Arrays

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhay Jain

Abhay Jain

Developer with 3 yrs of industrial experience in developing scalable web applications.

More from Medium

Conditional (ternary) operator in Javascript

Customizing a Drawer Element in a Quick App

What is Model-View-Controller (MVC)?

Creating web apps: the tale of a millennial JS developper