Which of the following is a falsy value in JavaScript?Options0 (number)true (boolean)[ ] (empty array)"false" (string)
Question
Which of the following is a falsy value in JavaScript?
Options:
0
(number)true
(boolean)[]
(empty array)- "false" (string)
Solution
In JavaScript, falsy values are values that evaluate to false
when coerced to a boolean. The following values are considered falsy:
false
(boolean)0
(number)""
(empty string)null
undefined
NaN
Now, let's evaluate the options provided:
- 0 (number): This is a falsy value.
- true (boolean): This is a truthy value.
- [] (empty array): An empty array is considered a truthy value in JavaScript.
- "false" (string): This string is considered a truthy value because any non-empty string is truthy.
Final Answer
The falsy value among the options is 0 (number).
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.