== vs === in JavaScript | Which one is better? | Strict vs Loose Equality
Автор: dcode
Загружено: 2018-04-18
Просмотров: 11688
Generally, you have two options when performing equality checks in JavaScript - you're going to be using the Abstract Equality Comparison (==) or the Strict Equality Comparison (===). They are both similar and appear to achieve the same outcome, but they are actually very different under the surface.
The == operator will automatically convert the types of the two values behind the scenes and only then will it make the actual comparison check. This is opposed to the === operator which takes data type into account, meaning a String will never be equal to a Number.
In this video I go through these differences with simple examples and you should be able to fully understand the difference after watching this quick 4 minute video.
My advice, go with the triple equals (===) :)
For your reference, check this out:
https://developer.mozilla.org/en-US/d...
Follow me on Twitter @dcode!
If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: