‘=’ is for assigning one value to the other variable.
‘==’ is for the comparison between string with number, number with number etc.
‘===’ is for the comparison between only number with number and string with string.
// for '=' operator
It will be true if it not contains any zero, false, and any empty string.
//for '==' operator
Suppose the value of x is "5" and the value of y, z is 8, -3 then the if condition will return value true. Here we are comparing string with the number.
//for '===' operator
The above example is not possible for this case because x value and the result of y+z value are either number and string. It will work on the below example.
if(5 === y + z)
Asked In: Many Interviews |