---
title: "Discussion on \"Why you shouldn't use Double Equals Operator in JavaScript\" | Hashnode"
description: "Discussion on \"Why you shouldn't use Double Equals Operator in JavaScript\". Unlike many other programming languages JavaScript has both double equals '=='   and triple equals  '==='  comparison operator. \nThey might seem to do the same exact thing, but there is one major difference between the two that makes triple equals al..."
url: "https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Why you shouldn't use Double Equals Operator in JavaScript](https://blog.hrithwik.dev/lose-equality-and-strict-equality-in-javascript?utm_source=hashnode&utm_medium=feed)

Unlike many other programming languages JavaScript has both double equals '==' and triple equals '===' comparison operator. They might seem to do the same exact thing, but there is one major difference between the two that makes triple equals al...

Sep 2, 2020 · 2 min read · blog.hrithwik.dev  
Updated Jun 17, 2021  
Read the article

-   [#hashnode](https://hashnode.com/tag/hashnode)
-   [#2articles1week](https://hashnode.com/tag/2articles1week)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#hashnodecommunity](https://hashnode.com/tag/hashnodecommunity)

## Written by

[Hrithwik Bharadwaj](https://hashnode.com/@hrithwik)

@hrithwik · Bangalore, India

  
[View profile](https://hashnode.com/@hrithwik)

Software Engineer ,Tech Enthusiast, Violinist

I am a full stack developer from Mysore India. I am here to share as much information I know with the world in the most articulate way.

## Responses 10

Markdown supported · ⌘↵ to post

[Juan David](https://hashnode.com/@juanmany)

[Nov 17, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5fb444a6b589f1618af9de32)

la verdad es algo que es tan basico que se aborda en la documentación y lo dejamos pasar. Que buen aclaración.

[Ikeh Leonard](https://hashnode.com/@Wazza)

[Oct 16, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f894bf76eb39417ce5e4cc5)

Good and simple read

[fengxh](https://hashnode.com/@fengxh)

[Sep 3, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f50a7fe98ae9829ac3dabda)

Sometimes, the type of data which are retrieved from apis is bitter vague, such as { code: 2, name: 'fengxh', type: 'human' } or { code: '2', type: 'clothes' }, from two different apis. So more codes to directly use `===`, unless a workaround `+code === 2`. But I still recommend using `===`

[Iverson Pereira](https://hashnode.com/@ilp)

[Sep 3, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f50607798ae9829ac3da90c)

In section **"The '===' Operator"** the result of :

```
let a=1;
let b='1'; 
let c=true;
console.log(a===b);
console.log(a==c);
```

the output on the console wouldn't be:

```
false
true
```

?

Very good article, thank you.

[Sep 3, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f50607798ae9829ac3da90c#reply-5f50859e98ae9829ac3da9fa)

Oops thanks for pointing out . I wanted to use triple equal in both the ones

[Prateek Gogia](https://hashnode.com/@reeversedev)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f987aa71a722802ba59c5)

I really liked the way you have used images.

Awesome stuff!

[Hrithwik Bharadwaj](https://hashnode.com/@hrithwik)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f987aa71a722802ba59c5#reply-5f4fe4dc98ae9829ac3da5ff)

Thanks mate

[Peter Thaleikis](https://hashnode.com/@spekulatius)

[Sep 14, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f987aa71a722802ba59c5#reply-5f5f99a601b5eb7613659491)

Thought the same :D

[double](https://hashnode.com/@equals)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f6da6f6e5c425ea69636d)

\== or riot

[Julian](https://hashnode.com/@wysiwyg)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f6da6f6e5c425ea69636d#reply-5f4f6efac0ee3d260ba90420)

Let's do a riot

[Triple](https://hashnode.com/@Triple)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f6da6f6e5c425ea69636d#reply-5f4f6fa6f6e5c425ea696399)

u wanna fight hu

[Prateek Aher](https://hashnode.com/@prateek_aher)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f6ba6c0ee3d260ba903d4)

I like the cover image you used [Hrithwik](https://hashnode.com/@hrithwik).

[Hrithwik Bharadwaj](https://hashnode.com/@hrithwik)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f6ba6c0ee3d260ba903d4#reply-5f4f7013c0ee3d260ba9043d)

Haha, Thanks [Prateek Aher](https://hashnode.com/@prateek_aher)

[Dinys Monvoisin](https://hashnode.com/@dinmon)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f65aff6e5c425ea69627b)

The title of your post does not match your conclusion. The reason people tend to use triple equals is that they are not entirely sure what they are comparing. However, if you know both operands is a certain type, double equals are fine.

If you would tell me to write a web application from scratch, I would use double equals, the reason is to force people to write deterministic code.

[Dinys Monvoisin](https://hashnode.com/@dinmon)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f65aff6e5c425ea69627b#reply-5f4f9e25397a30282ba3867c)

[Tapas Adhikary](https://hashnode.com/@atapas),

If I am not mistaken `Object.is` one of the edge cases is `-0`. There are only a few such cases. Therefore, I prefer to stick with `==` as it is less verbose and only recommend using `Object.is` only for those.

However, many people do not know the various coercions of `==`, but most of the obscure one like `"" == false` should at first hand never see the day in the application you develop.

[Mark](https://hashnode.com/@mverleg)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f65aff6e5c425ea69627b#reply-5f50087098ae9829ac3da712)

What do you mean by deterministic code? The way I understand determinism, it's unrelated to `==`.

I would agree it's better to know the types of things you're comparing. But it doesn't hurt to use `===` to prevent surprises, right? Experienced developers are not immune to making mistakes.

[Dinys Monvoisin](https://hashnode.com/@dinmon)

[Sep 3, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f65aff6e5c425ea69627b#reply-5f5089c498ae9829ac3daa21)

Determinism in terms of the types you are comparing.

I would not argue any further, it a preference, a choice you make.

Think about it. If you know both types are the same, putting an extra `=` to make `===`, isn't redundant.

Anyway, those things are agreed upon in a coding convention done by your team. If you usually use `===`, it is okay.

[Sandeep Panda](https://hashnode.com/@sandeep)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f6036c0ee3d260ba90293)

Thanks for the tip. I recommend using === almost every time unless there is a compelling reason not to. == can introduce unexpected bugs that are hard to find and fix.

[Hrithwik Bharadwaj](https://hashnode.com/@hrithwik)

[Sep 2, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f6036c0ee3d260ba90293#reply-5f4fabf8a71a722802ba5adb)

Yup

[Peter Thaleikis](https://hashnode.com/@spekulatius)

[Sep 14, 2020](https://hashnode.com/posts/lose-equality-and-strict-equality-in-javascript/5f4f5b5af6e5c425ea6960fe/comment/5f4f6036c0ee3d260ba90293#reply-5f5f998a01b5eb7613659483)

Pretty much sums it up 👍️
