How to Remove a Specific Value from an Array in JavaScript
In this lesson, we will see how to remove a specific value from an array in JavaScript, sometimes we want to remove a particular value from an existing array so how we can do that?
The splice() method
To do that we can use the splice() method that takes the value index and how many values to remove here we remove only one which is the value that has index 2.
const colors = ["blue", "orange", "black", "red"];
colors.splice(2,1);
console.log(colors);
//['blue', 'orange', 'red']