java-script:falsy-truthy-values
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
java-script:falsy-truthy-values [2023/08/09 20:44] – removed - external edit (Unknown date) 127.0.0.1 | java-script:falsy-truthy-values [2023/08/09 20:47] (current) – odefta | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Java Script Falsy and Truthy Values ====== | ||
+ | |||
+ | ===== Falsy values ===== | ||
+ | |||
+ | A falsy value is a value considered false if it's encountered in a boolean context. | ||
+ | |||
+ | These are the falsy values: | ||
+ | - **false**: The keyword false itself is obviously considered falsy. | ||
+ | - **0, -0, 0n, -0n**: The number zero (including its negative counterpart and big int) is considered falsy. | ||
+ | - **"", | ||
+ | - **null**: The null keyword is considered falsy. | ||
+ | - **undefined**: | ||
+ | - **NaN**: "Not a Number" | ||
+ | |||
+ | ===== Truthy values ===== | ||
+ | |||
+ | Everything that is not a falsy value is a truthy value. | ||
+ | This includes: | ||
+ | * **' | ||
+ | * **' | ||
+ | * **[]** | ||
+ | * **{}** | ||
+ | * **function () {}** | ||
+ | | ||