From 0b938bf8080ae09a966378b10963d263429b5181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobi=20Sch=C3=A4fer?= Date: Sat, 21 Mar 2020 13:13:20 +0100 Subject: [PATCH] chg: refactored and simplified Array.union() method --- modules/core/Array.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/modules/core/Array.js b/modules/core/Array.js index e63c20fe..099f3183 100644 --- a/modules/core/Array.js +++ b/modules/core/Array.js @@ -38,18 +38,9 @@ Array.prototype.contains = Array.prototype.includes * @return {Array} the union set */ Array.union = function() { - var result = []; - var map = {}; - for (var i=0; i { + return result.concat(array.filter(element => !result.includes(element))); + }, []); }; /**