I'm newbie in JS, I know that ==
double comparation for equality and ===
triple one for equality and type. My teacher says that I should use always triple. However, I don't see any down effect if I use double equal when one of the elements is a string.
'' == 0 // true
'10' == 10 // true
'dog' == 'cat' // false
So, I'm using always double equal when some of the element is a string (avoiding this 'false' == false
) and triple when I'm detecting null
or undefined
.
Is there any down side for my approach?
I checked this previous answer: Which equals operator (== vs ===) should be used in JavaScript comparisons?