Hi,
Can anyone explain about === in js.
What is the difference between == and ===?
thanks
Punitha Pary

Put in simple terms, both are comparison operators of Javascript with the difference being that === is a type safe / type aware operator. If two operands are of the same type and same value, only then the === returns true. Whereas, in case of == if the two operands are not of the same type, they try to coerce the values.

1 == '1'  //  true
1 === '1' // false

Its always better to use === and !== whenever possible to avoid surprises.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.