In javascript both “==” and “===” used for comparison but they have purposes and behaviors
== (Double equal)
:
The == operator is used for loose equality comparison . When we compare with == it will only compare values not the data type means if we compare string of “5” and integer 5 the result will be true
console.log(5=="5") // true
console.log(5==5) // true
2. === (triple equal):
The === operator is used for strict equality comparison. As we studied == only compare values not data type but === compare both values and datatype means if we compare string of “5” and integer 5 the result will be false both values and data type must same
console.log(5=="5") // false
console.log(5==5) // true
Top comments (0)