JavaScript — Double Equals VS Triple Equals ✨
JavaScript has two visually similar, yet very different, ways to test equality. 🤓
You can test equality with == or === 🔅
Triple Equals ✅
When using triple equals === in JavaScript, we are testing for strict equality.
This means both the type and the value we are comparing have to be the same.
Example :
🔹🔸🔹🔸
Double equals ✅
When using double equals in JavaScript we are testing for loose equality.
Double equals also performs type coercion.
Example :
https://t.me/pgimg/61
[ Article ] : http://bit.do/jseq
〰〰〰〰〰〰
#JavaScript #Equality
@ProgrammingTip
JavaScript has two visually similar, yet very different, ways to test equality. 🤓
You can test equality with == or === 🔅
Triple Equals ✅
When using triple equals === in JavaScript, we are testing for strict equality.
This means both the type and the value we are comparing have to be the same.
Example :
77 === '77'
// false (Number v. String)
🔹🔸🔹🔸
Double equals ✅
When using double equals in JavaScript we are testing for loose equality.
Double equals also performs type coercion.
Example :
77 == '77'
// true
https://t.me/pgimg/61
[ Article ] : http://bit.do/jseq
〰〰〰〰〰〰
#JavaScript #Equality
@ProgrammingTip
Telegram
Programming Tips Resources