Difference between == and ===

Should you use == or === for comparison in your code? What is the difference?

Two equal signs == are called “equality operator” or “abstract comparison.” They compare only values.

Three equal signs === are called “identity operator” or “strict comparison.” They compare values and data types as well.

Example:

There also exist inequality operators != and !==.

Show your support

Clapping shows how much you appreciated Tomáš Holub’s story.