truthy values issue explained

pull/989/head
Aayan Patel 5 months ago committed by GitHub
parent 29e4101818
commit 02a28858ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -76,6 +76,17 @@ We agreed that boolean values are either true or false.
- All strings are truthy except an empty string ('')
- The boolean true
#### ⚠️ Note:
Even though non-zero numbers and decimal numbers(like -1,1.5,etc) are truthy in a Boolean context, they are not equal to true when using ==.
Example: Truthy but not equal to true
if (-1) → Evaluates to true because -1 is truthy.
-1 == true → Returns false because true is coerced to 1, and -1 is not equal to 1.
To explicitly check the truthiness of a value, use Boolean(value) or use them in if-else , while or do-while conditional statements.
### Falsy values
- 0

Loading…
Cancel
Save