Search code examples
javascriptgoogle-chrome-extension

array.splice() removes the content of an entry but not an entry itself


I am trying to remove an entry from an array using array.splice(), using this bit of code:

let replaceThisArrRemoved = replaceThisArr.splice(positionNumber, 1);

When I use replaceThisArr = ["apple", "orange", "pear"] and positionNumber = 1, it will return replaceThisArr = ["apple", "", pear"].

I am trying to get it to return replaceThisArr = ["apple", "pear"]

Is there any other way of doing this, or anything wrong with my code that I should fix?


Solution

  • look at this console output -

    enter image description here