Javascript

== vs === operators vs Object.is() in JavaScript

== Operator

•“==‘’ operator is used to compare two values.

•It does not check the data type of operands while comparisons.

•Rather it performs the type Coercion while comparing.

=== operator (strict equality )

•“===‘’ operator is also used to compare two values.

•It checks not only the values but also types of two variables.

•It does perform the type Coercion while comparing.

Object.is()

•Object.is() overcomes the limitations of “===” operator.

•Object.is(NaN, NaN) is true;

•Object.is(0, -0) is false;

•Rest all behavior is similar to that of strict equality operator.

Please check below video to look into detailed explaination with examples in == vs === vs Object.is() in JavaScrtipt:

Please let me know in comment section of video, if you have any questions related to this topic.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s