From dacade6fccb9f1191c92682bfc4ddb0bff9b9064 Mon Sep 17 00:00:00 2001 From: Jo Wroten Date: Tue, 9 Jul 2019 20:33:20 +0000 Subject: [PATCH] =?UTF-8?q?Update=20Posts=20=E2=80=9Cusing-js-sets-to-find?= =?UTF-8?q?-elements=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/posts/using-js-sets-to-find-elements.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/content/posts/using-js-sets-to-find-elements.md b/content/posts/using-js-sets-to-find-elements.md index 51fabdf..49ca705 100644 --- a/content/posts/using-js-sets-to-find-elements.md +++ b/content/posts/using-js-sets-to-find-elements.md @@ -26,7 +26,11 @@ description: >- ``` --- -Functionally for one check, this is identical to checking the `.indexOf()` or `.includes()` of an Array. However, in cases where you're filtering a large array down to match a list of ID's, for example, the nested looping can result in a performance hit. Traditionally hash tables were used for speeding up this search, but with ES2015 we can now leverage Sets which are easier to read and still result in a single loop that's equal to the length of the Array and no more. (Can be further optimized by ending when running out of needles) +Functionally for one check, this is identical to checking the `.indexOf()` or `.includes()` of an Array. However, in cases where you're filtering a large array down to match a list of ID's, for example, the nested looping can result in a performance hit. + +Traditionally hash tables were used for speeding up this search, but with ES2015 we can now leverage Sets which are easier to read and still result in a single loop that's equal to the length of the Array and no more. + +(Can be further optimized by ending when running out of needles) ```js // Example Data