Real Problems! Real Experts!

An unparalleled, New approach On creative thinking and problem solving.

The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we help you to solve your academic and programming questions fast.
In eduladder you can Ask,Answer,Listen,Earn and Download Questions and Question papers.
Watch related videos of your favorite subject.
Connect with students from different parts of the world.
Apply or Post Jobs, Courses ,Internships and Volunteering opportunity. For FREE
See Our team
Wondering how we keep quality?
Got unsolved questions? Ask Questions


Asked On2019-08-16 18:34:38 by:Annaliya

Taged users:


Be first to dislike this question
Talk about this  Like  Dislike
View all questions

Difference between == and ===  in JavaScript

Since JavaScript support both strict equality and type-converting equality, it's important to know which operator is used for which operation. As I said that, === takes type of variable in consideration, while == make type correction based upon values of variables, following are couple of more differences between "==" and "===" operator in JavaScript programming language :

1) When we compare two variables of different type e.g. a boolean with a string or a number with String using == operator, it automatically converts one type into another and return value based upon content equality, while === operator is strict equality operator in Java, and only return true if both variable of same type and also contains same value. This will be much clear with following example of == and === operator in JavaScript :

0==false   // true, because false is equivalent of 0
0===false  // false, because both operands are of different type
2=="2"     // true, auto type coercion, string converted into number
2==="2"    // false, since both operands are not of same type

2)  "==" operator is known as type coercion operator and anytime if both values are same and compared using ==operator, type coercion happens. On the other hand === is known as strictly equality operator. It's much similar Java's equality operator (==), which gives compilation error if you compare two variables, whose types are not compatible to each other. In fact, you should always use "===" operator for comparing variables or just for any comparison. 

3)  While comparing variable using strict equality operator in Java, two object are strictly equal to each other if both are of same type and they refer to same instance. Similarly two String are equal to each other if contents of each others are same e.g. same characters at same position. Another good follow-up question is what would be result of comparing null and undefined using == and === operator in JavaScript. Well answer is simple, when you use "==" operator it will return true, while if you use "===" or strict equality operator, it will return false. 

4) One more follow-up question of == vs === operator is difference between != and !== operator in JavaScript. I think it's pretty easy to deduct that !== operator is strict non equality operator, which will take type into consideration while comparing two variables or two values in JavaScript.

5) Last but not the least question related to this JavaScript interview question is, what happen if you compare Nan with any number or Nan itself, using  === operator,  You should remember that NaN (Not a Number) is not equal to anything, including NaN.

Answerd on:2019-08-21 Answerd By:Annaliya

Be first to like this answer

Be first to dislike this answer
Talk about this  Like  Dislike

You might like this video:Watch more here

Watch more videos from this user Here

Learn how to upload a video over here

Lets together make the web is a better place

We made eduladder by keeping the ideology of building a supermarket of all the educational material available under one roof. We are doing it with the help of individual contributors like you, interns and employees. So the resources you are looking for can be easily available and accessible also with the freedom of remix reuse and reshare our content under the terms of creative commons license with attribution required close.

You can also contribute to our vision of "Helping student to pass any exams" with these.
Answer a question: You can answer the questions not yet answered in eduladder.How to answer a question
Career: Work or do your internship with us.Work with us
Create a video: You can teach anything and everything each video should be less than five minutes should cover the idea less than five min.How to upload a video on eduladder