Which of the following is a falsy value in JavaScript?Options[ ] (empty array)"false" (string)0 (number)true (boolean)
Question
Which of the following is a falsy value in JavaScript?
Options:
[]
(empty array)- "false" (string)
0
(number)true
(boolean)
Solution
In JavaScript, a falsy value is a value that translates to false
when evaluated in a boolean context. The falsy values in JavaScript include false
, 0
, ""
(empty string), null
, undefined
, and NaN
.
Let's analyze the options provided:
- (empty array): In JavaScript, an empty array
[]
is considered a truthy value. - "false" (string): Despite the string containing the word "false", it is still a non-empty string and is therefore truthy.
- 0 (number): The number
0
is a falsy value in JavaScript. - true (boolean): The boolean value
true
is definitely a truthy value.
Based on this analysis, among the given options, the falsy value in JavaScript is:
Final Answer
0 (number) is the falsy value.
Similar Questions
Which of the following is not a primitive data type in JavaScript?Group of answer choicesNumberStringBooleanArray
Which of these values can a boolean variable contain?Options0 & 1true & falseAny integer valuetrue
What is the default value of boolean?Options: Pick one correct answer from belowtruefalse
What is the output of following code?var a = 10;function test() { a = 20;}test();console.log(a);Options: Pick one correct answer from below1020
An array is a reference to multiple variables. State true or false.a)Falseb)True
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.