JavaScript - Remove specific value from array with filter()
A JavaScript code example for removing a specific value from an array.
The HTML has an output element with id "output" to display the result.
<p id="output"></p>
The filter()
method can be used to remove a specific value from an array.
By writing the filter()
method as below, it returns the array with the specified value removed.
let array = ['Apple', 'Banana', 'Grape'];
// Remove specific value from array
array = array.filter(item => item !== 'Apple');
console.log(array);
document.querySelector('#output').innerHTML = array;
TitleJavaScript - Remove specific value from array with filter()
CategoryJavaScript
Created
Update
AuthorYousuke.U