JavaScript Challenge #7

Posted by Danielle Torres on February 8, 2021

Explan equality in JavaScript?

When comparing values for equality, JavaScript provides three different value-comparison operations.

Strict Comparison (===), checks for value equality without allowing coercion.

Imgur

Abstract comparison (==), checks for value equality with coercion allowed.

Imgur

Do not use Abstract Comparisons if:

  • The value on either side of the comparison can be true or false.
  • The value on either side of the comparison can be zero, “ “, or an empty array.

One Example:

Oh no! True returns when comparing a string and an integer. We only want true when its the same value and data type.

Imgur

Thats better!

Imgur

That wasn’t so bad was it? Let’s continue!

We also have another comparison operator called Object.is. This method compares two values and determine if they are the same type. How cool is that!

Imgur

Hope everyone found today’s topic interesting. Please be here for my next blog when we review another Javascript challenge! Remember don’t just ready about it! Code about it!

Until next time…