From 9bf26b915044b73c4be726eb1517e075f2cb5639 Mon Sep 17 00:00:00 2001 From: Ragunathan Maniraj Date: Tue, 16 Oct 2018 10:30:23 +0530 Subject: [PATCH] added rules for truthy values (#19414) --- .../pages/guide/english/javascript/truthy-values/index.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/src/pages/guide/english/javascript/truthy-values/index.md b/client/src/pages/guide/english/javascript/truthy-values/index.md index eb4dd14c91..0612665651 100644 --- a/client/src/pages/guide/english/javascript/truthy-values/index.md +++ b/client/src/pages/guide/english/javascript/truthy-values/index.md @@ -13,6 +13,14 @@ Some interesting **truthy** values are: {} (an empty object) function(){} (an “empty” function) +**Rules:** +* `false`, `zero` and `''`(empty strings) are all equivalent. +* `null` and `undefined` are equivalent to themselves and each other but nothing else. +* `NaN` is not equivalent to anything – including another `NaN! +* `Infinity` is truthy – but cannot be compared to `true` or `false`! +* An empty array(`[]`) is truthy – yet comparing with `true` is `false` and comparing with `false` is `true`?! + + A single value can therefore be used within conditions, e.g. if (value) {