Junior
Millised väärtused JavaScriptis loetakse falsy väärtusteks?
sobes.tech AI
Vastus AI-lt
In JavaScript, the "falsy" values include:
false- The boolean valuefalse.0- Numeric zero (both integer and floating point, e.g.,0.0).-0- Negative zero.""- Empty string.null- A special value indicating "the absence of any object".undefined- The default value of a variable if no other value is assigned, and also the result of accessing a non-existent property of an object.NaN- Not-a-Number, the result of incorrect mathematical operations.
These values are converted to false when used in a boolean context, such as in an if condition. All other values (objects, arrays, non-empty strings, numbers other than zero, etc.) are considered "truthy" (true).