From c7ccd4c64b57ceab3210f910085c589740d57602 Mon Sep 17 00:00:00 2001 From: Danny Kirschner Date: Wed, 7 Nov 2018 13:38:56 -0500 Subject: [PATCH] Adding another way to check falsey boolean values (#21129) Checking using !! to get the boolean value may be easier than setting up a conditional. Also linking to the truthy freeCodeCamp guide. --- guide/english/javascript/falsy-values/index.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/guide/english/javascript/falsy-values/index.md b/guide/english/javascript/falsy-values/index.md index dff576c71d..89f746dabb 100644 --- a/guide/english/javascript/falsy-values/index.md +++ b/guide/english/javascript/falsy-values/index.md @@ -4,7 +4,7 @@ title: Falsy Values ## Description -A falsy value is something which evaluates to FALSE, for instance when checking a variable. There are only six falsy values in JavaScript: `undefined`, `null`, `NaN`, `0`, `""` or `''` (empty string), and `false` of course. +A falsy value is something which evaluates to FALSE, for instance when checking a variable. There are only six falsy values in JavaScript: `undefined`, `null`, `NaN`, `0`, `""` or `''` (empty string), and the Boolean `false` of course. All other values are [truthy](https://github.com/freeCodeCamp/freeCodeCamp/edit/master/guide/english/javascript/truthy-values/index.md). ## Checking for falsy values on variables @@ -16,6 +16,11 @@ if (!variable) { } ``` +You can also get the boolean value of a variable by using the bang operator (`!`) twice: +```javascript +!!variable // When the variable is falsy, a double bang (!!) will evaluate to the Boolean false. +``` + ## General Examples ```javascript