To remove item from array using its name / value with JavaScript, we use the filter method.
For instance, we write
const COUNTRY_ID = "AL";
countries.results = countries.results.filter((el) => {
return el.id !== COUNTRY_ID;
});
to call filter with a callback to return an array within the countries.results array without the object with id not equal to COUNTRY_ID.
Latest comments (1)
cpu killer, go to jail