In this post, I have discussed 5 basic javascript question and answer that is mostly asked in the interviews. Most of the time interviewer starts the interview with some of these basic questions. So here we have Q1. What is the difference between == and ===? Solution : When we want to test the equality of two values(LHS and RHS), we use == or ===. == is basically used to check if the two values are equal or not,and we are not considering their datatype. e.g. if we check 5 == "5" // true as values are equal undefined = null // true as both represents NO VALUE In case of ===, we not only consider the values but the datatype as well.e.g. 5 === "5" // false as though values are equal but datatypes are different Similarly undefined === null // false, as datatype of undefined and null is undefined and object respectively It is highly recommended to use === in the programming as we get very unexpected results out of ==. e.g. false == 0 /
Explore Javascript core concepts and various Js frameworks. Understand behind the scene working of Javascript engine in easy language with various simple examples.