Skip to content

Commit f533b66

Browse files
authored
How to convert truthy/falsy to boolean(true/false)
1 parent d3286fd commit f533b66

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# JavaScript-snippets
2-
JavaScript Snippets
2+
find us on [Facebook](https://www.facebook.com/snippetsJS)
33

44

55
# How to generate a random number in a given range
@@ -60,4 +60,20 @@ const difference = (a, b) => {
6060

6161
difference(firstArr, secondArr); //[3,4]
6262
console.log('difference',difference(firstArr, secondArr))
63+
```
64+
65+
# How to convert truthy/falsy to boolean(true/false)
66+
```javascript
67+
const myVar = null;
68+
const mySecondVar = 1;
69+
70+
console.log( Boolean(myVar) ) // false
71+
console.log( !!myVar ) // false
72+
73+
74+
console.log( Boolean(mySecondVar) ) // true
75+
console.log( !!mySecondVar ) // true
76+
77+
78+
6379
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy