Which of the following is NOT a falsy value in JavaScript?

Prepare for the Salesforce JavaScript Developer I Certification Exam. Utilize interactive quizzes, flashcards, and detailed explanations for each question. Boost your confidence and ace your exam effortlessly!

In JavaScript, a falsy value is a value that translates to false when evaluated in a Boolean context. Common falsy values include false, 0, '' (an empty string), null, undefined, and NaN.

The answer indicating that "new Boolean(false)" is not a falsy value is correct because this expression creates a Boolean object, which is an instance of the Boolean class. Unlike primitive Boolean values, objects in JavaScript are always considered truthy, regardless of their internal state. This means that even though the value inside the Boolean object is false, the object itself is truthy when evaluated in a Boolean context.

The other values, such as false, 0, and '', are all standard falsy values in JavaScript. Therefore, "new Boolean(false)" stands out as it does not align with the definition of falsy values and is accurately identified as not being a falsy value.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy