I have an array:
arr = ["a","b","c"];
How could I do in order to remove value "c" and then return array ["a","b"]?
I have an array:
arr = ["a","b","c"];
How could I do in order to remove value "c" and then return array ["a","b"]?
You can find the index of the item being removed with Array.prototype.indexOf and you can eliminate the particular element with Array.prototype.splice, like this
var arr = ["a","b","c"];
arr.splice(arr.indexOf("c"), 1);
console.log(arr);
# [ 'a', 'b' ]
The second parameter passed to splice is to instruct how many elements to be removed from the index specified with the first parameter.
c is in the middle?pop because it is not clear from the question which is more suited to the OP's use case. If the element to be removed always happens to be last, no need to compute indexOf.