Open rauschma opened 6 years ago
Section 14.3
Maybe also good to mention falsy value from Bigint 0n
?
if (x) { // truthy?
// x is neither: undefined, null, false, 0, NaN, ''
}
as well in this example:
if (!x) { // falsy?
// x is: undefined, null, false, 0, NaN, ''
}
@LukasMac Good catch, thanks! This will be fixed in the next release.
I find strange that in the section
Is x either undefined or null?
only the natural/trivial comparison is mentioned
if (x === undefined || x === null) { ... }
and not the equivalent and terser alternative
if (x == null) { ... }
@leonbloy Yes, you make a good point, I think we can also use the x== null
as null == undefined
to check if x
is either undefined or null. @rauschma I wonder whats wrong in here?
@leonbloy, @yanjankaf take a look at this section: 13.4.3.2 Use case for ==: comparing with undefined or null for the explanation of why if (x == null) { ... }
is not preferred.
Section 13.4 starts:
should be "...only two..."