Content: Number of falsy values

Created on 14 Jan 2021  Â·  5Comments  Â·  Source: mdn/content

I tried to search for a similar issue or PR but couldn't find it:

In https://developer.mozilla.org/en-US/docs/Glossary/Falsy it mentions there are 8 falsy values. And it shows 0, -0 and 0n.

Shouldn't it be 9 falsy values if we include -0n?
Or if we don't include -0n, shouldn't it be 7 falsy values?

This is a bit of a curiosity issue, I'm not sure if there is a valid reason to exclude the -0n.

Thank you and big big thanks for all the work you've done!

Most helpful comment

Thanks much for raising this issue — I’ve opened https://github.com/mdn/content/pull/1316 with an update.

It seems best to not put any number at all; so one thing that the #1316 patch does is, it replaces that There are 8 falsy values statement, with a Complete list of JavaScript falsy values table caption.

All 5 comments

Thanks much for raising this issue — I’ve opened https://github.com/mdn/content/pull/1316 with an update.

It seems best to not put any number at all; so one thing that the #1316 patch does is, it replaces that There are 8 falsy values statement, with a Complete list of JavaScript falsy values table caption.

I'm the one who originally wrote "8 values" in the wiki.

The reason is that 0 and -0 are really different values, whereas 0n and -0n are the same value.

> Object.is(0, -0)
false
> Object.is(0n, -0n)
true

More specifically, 0 and -0 are not observationally equivalent, as the following program shows:

> 1 / 0
Infinity
> 1 / (-0)
-Infinity

I think it's fine to not put any number at all, as @sideshowbarker did, but please put 0 and -0 in different rows. They really are different values.

please put 0 and -0 in different rows. They really are different values.

Fair enough. I’ve raised https://github.com/mdn/content/pull/1931 for that

The points brought by @sorawee are very interesting.

I was investigating the Object.is and the Equality Comparison table trying to find more information about it but I was not finding anything.

So I have 2 suggestions that should make that information more visible:

On the Object.is page add the Object.is(0n, -0n) to the special cases.

// Special Cases
Object.is(0n, -0n);            // true
...

On the Equality Comparison add the information to the table:

| x | y | == | === | Object.is | SameValueZero |
|-------------| -------------| -------------| -------------| ------------- | ------------- |
|0n | -0n | true | true | true | true |

If you'd like I can help with a PR.

Even if these changes make no sense, I just want to thank you for your replies and your great work on MDN.

So I have 2 suggestions that should make that information more visible:

On the Object.is page add the Object.is(0n, -0n) to the special cases.
…

On the Equality Comparison add the information to the table:
x y == === Object.is SameValueZero
0n -0n true true true true

If you'd like I can help with a PR.

Both of those changes look great to me, so a PR would be very much welcome.

Was this page helpful?
0 / 5 - 0 ratings