File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change 1
- // truthy-falsy.js
2
-
3
- // INFO: What are Truthy and Falsy Values?
4
-
5
- /*
1
+ /* INFO: What are Truthy and Falsy Values?
6
2
In JavaScript, every value is either "truthy" or "falsy" when evaluated in a Boolean context (like inside an if condition).
7
3
8
- - **Falsy values** are those that are considered false when converted to a Boolean.
9
- - **Truthy values** are all other values that are considered true.
10
-
11
- Knowing which values are falsy helps avoid bugs and write cleaner conditions.
12
-
13
- ---
4
+ - Falsy values** are those that are considered false when converted to a Boolean.
5
+ - Truthy values** are all other values that are considered true.
6
+ */
14
7
8
+ /*
15
9
JavaScript's falsy values are exactly these:
16
10
17
11
1. false
@@ -25,7 +19,7 @@ JavaScript's falsy values are exactly these:
25
19
Everything else is truthy.
26
20
*/
27
21
28
- // NOTE: Falsy Values in JavaScript
22
+ // Falsy Values in JavaScript
29
23
if ( ! false ) console . log ( "false is falsy" ) ;
30
24
if ( ! 0 ) console . log ( "0 is falsy" ) ;
31
25
if ( ! - 0 ) console . log ( "-0 is falsy" ) ;
You can’t perform that action at this time.
0 commit comments