How to filter array and remove unwanted items 2022

published: 08 Oct 2022

1 min read

A cool little snippet to remove items from an array


const urls = [
 "image.jpg",
 "image.jpeg",
 "image.png",
 "image.webp",
 "image.svg",
 "image.gif",
];
const result = urls.filter((url) => /\.(jpe?g|png|webp)$/.test(url));
console.log(result);


How to filter array and remove unwanted items 2022 | Coding Tips And Tricks

Are we missing something?  Help us improve this article. Reach out to us.

Are you looking for other code tips?

Check out what's on in the category: javascript, programming
Check out what's on in the tag: javascript, programming

TipsAndTricksta

I love coding, I love coding tips & tricks, code snippets and javascript