From 66814950d976d0727587af42296c321404795c6c Mon Sep 17 00:00:00 2001 From: Davis Sorenson Date: Tue, 30 Aug 2016 23:12:56 +0300 Subject: [PATCH] Make the boolean conditionals examples equivalent `array.indexOf(i) >= -1` will return `true` when `array.indexOf(i)` is -1 or greater. `array.indexOf(i) !== -1` will return `true` when `array.indexOf(i)` is not -1. Since `Array.prototype.indexOf` returns values starting from -1, that is equivalent to `array.indexOf(i) >= 0`. This pull request makes both expressions equivalent. --- workflow/boolean-conditions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow/boolean-conditions.md b/workflow/boolean-conditions.md index 6de5d27..a845a76 100644 --- a/workflow/boolean-conditions.md +++ b/workflow/boolean-conditions.md @@ -4,8 +4,8 @@ Avoid using `>=` and `<=` unless necessary. It's faster to use a simpler compari ```js // slow -// two boolean conditions: `=== -1` and `> -1` -array.indexOf(i) >= -1 +// two boolean conditions: `=== 0` and `> 0` +array.indexOf(i) >= 0 // fast // just one boolean condition: `!== -1`