What is the difference between the equality operators == and ===?
ReportPlease briefly explain why you feel this question should be reported .
Equality operators:
The equality operator converts the operands if they are not of the same type, then applies strict comparison. If both operands are objects, then JavaScript compares internal references which are equal when operands refer to the same object in memory.
Syntax:
x == y
Examples:
1 == 1 // true 1 == '1' // true '1' == 1 // true 0 == false // true 0 == null // false var object1 = {'key': 'value'}, object2 = {'key': 'value'}; object1 == object2 //false 0 == undefined // false null == undefined // true
Strict equality (===)
Triple equals (===
) checks for strict equality, which means both the type and value must be the same.
Syntax:
x == y
1 === 1 // true 1 === '1' // false var object1 = {'key': 'value'}, object2 = {'key': 'value'}; object1 === object2 //false
Leave an answer