By Kevin Hou
1 minute read
For the longest time, I didn't realize that '===' was a comparison operator in Javascript. I just recently learned what the difference between them was. The double equal signs tell the comparison statement to convert the two values into the same type before comparing them. The triple equal signs do not convert the values before coimparing. If the two values do not share the same type, it will simply return false. For example:
1var num = 1; 2var str = "1"; 3if (str == num) // Will return true 4if (str === num) // Will return false 5
This is a super short post, but I figured I should write it down since it was interesting and something I should remember.