Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce JS-Dev-101 Exam - Topic 1 Question 8 Discussion

Posted by Vanda on May 11, 2026 at 02:10 AM

Given a value, which two options can a developer use to detect if the value is NaN?

Suggested Answer: C, D

Comprehensive and Detailed Explanation From Exact Extract JavaScript knowledge:

We already know NaN is special: it is not equal to itself.

Check each:

A . value === Number.NaN

Number.NaN is NaN.

NaN === NaN is always false.

This will never be true; cannot reliably detect NaN.

B . value == NaN

NaN == NaN is also always false.

Again, this never detects NaN.

C . isNaN(value)

Global isNaN converts its argument to a number and then checks if the result is NaN.

This can detect NaN, but it may also return true for non-number values that coerce to NaN, such as isNaN('foo').

Regardless, it is a standard way to detect if a value is ''NaN-like'' in JavaScript.

D . Object.is(value, NaN)

Object.is(NaN, NaN) returns true.

This is a strict way to detect a value that is exactly NaN (no coercion).

Therefore, among the given choices, the two viable ways to detect NaN are:

isNaN(value)

Object.is(value, NaN)

________________________________________


Get Premium JS-Dev-101 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
24 comments · newest first
YU
Yun 2 days ago
Yes, but A won't return true for NaN.
WI
Wilbert 7 days ago
I'm confused about A. Isn't Number.NaN just NaN?
KA
Kathrine 13 days ago
Agreed! A and B won't work as expected.
YU
Yun 18 days ago
I think C is the best option. isNaN(value) is reliable.
FA
Fabiola 23 days ago
Definitely C. It’s the standard way to check!
DI
Dion 28 days ago
I feel confused about NaN sometimes. C makes it easier.
RE
Regenia 1 month ago
D is interesting, but C is more common.
FA
Fanny 1 month ago
A and B won't work. NaN is tricky!
AU
Audra 1 month ago
I agree with C. It's straightforward and clear.
RO
Rocco 2 months ago
I think C is the best choice. isNaN(value) is reliable.
ST
Starr 2 months ago
Wait, can you really use Object.is for NaN? That’s new to me!
MA
Maxima 2 months ago
I thought B) value == NaN would work, but it doesn't!
RO
Rolland 2 months ago
A) value === Number.NaN is not valid, right?
NI
Nichelle 2 months ago
D) Object.is(value, NaN) works too!
CA
Catherin 2 months ago
C) isNaN(value) is the way to go!
JA
Janet 3 months ago
I thought NaN was just NaN, how can you compare it?
JO
Jose 3 months ago
Wait, can you really use D? That seems odd.
JA
Jacqueline 3 months ago
A) value === Number.NaN is not valid, just a heads up!
LA
Lanie 3 months ago
D) Object.is(value, NaN) works too!
ER
Erick 3 months ago
C) isNaN(value) is the way to go!
LE
Leontine 4 months ago
I feel like both B and D are incorrect, but I can't remember why exactly.
BR
Brett 4 months ago
I practiced a similar question, and I think Object.is(value, NaN) might be valid too, but I can't recall the details.
CH
Chara 4 months ago
I think value === Number.NaN won't work because NaN is not equal to itself, right?
AN
Annelle 5 months ago
I remember that using isNaN(value) is a common way to check for NaN, but I'm not sure about the others.
0/2000 characters

Save Cancel