From eb94bdb05af2580bcf7f01a5b762f82f116514fb Mon Sep 17 00:00:00 2001 From: Denys Poltorak Date: Thu, 3 Aug 2023 14:59:39 +0300 Subject: [PATCH] refactor: add array check --- src/arrayMethodJoin.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/arrayMethodJoin.js b/src/arrayMethodJoin.js index cb39c800..fb37e954 100644 --- a/src/arrayMethodJoin.js +++ b/src/arrayMethodJoin.js @@ -9,6 +9,11 @@ const isNotIgnoredEl = (el) => ![null, undefined].includes(el); function applyCustomJoin() { [].__proto__.join2 = function(separator = ',') { const currentArray = this; + + if (!(currentArray instanceof Array)) { + return ''; + } + const INDEX_OF_LAST_ELEMENT = currentArray.length - 1; let concatedString = '';