Blog for web developers

Array Filter

Array filter is one of the array function that return the data filtering your matching condition.

Note I have used a regular expression to remove from unwanted special character such as modulus and dot (.) It simply says filter out the text from A-Z or a-z or 0-9 only.


["A", "quick", "brown", "fox", "jumps", "over", "a", "tunnel"]

If you would like to add more conditions like you want to filter if the string length is greater than, then you can use it like this.

let s = sent.split(/\W+/).filter(x=>x.length>2);
//["quick", "brown", "fox", "jumps", "over", "tunnel"];

Santosh Shah

I am a JavaScript developer having enthusiasm on most frontend skills like JavaScript, HTML, CSS, SASS, node, gulp, angular etc. I love exploring new techniques and like to learn new technologies to keep my self up to date.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.