From e17a79f14881c7ecb3b98cebc6f562d80ff087c2 Mon Sep 17 00:00:00 2001 From: "Kyle E. Mitchell" Date: Fri, 9 Jun 2017 22:02:10 -0700 Subject: [PATCH] Check element equality before replacing --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 958a403..c3a73b5 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ module.exports = remove function remove (arr, i) { if (i >= arr.length || i < 0) return var last = arr.pop() - if (i < arr.length) { + if (i < arr.length && arr[i] !== last) { var tmp = arr[i] arr[i] = last return tmp