Skip to content

Instantly share code, notes, and snippets.

@karlpokus
Created August 14, 2016 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlpokus/0b39d52d8fcb3b663cd5950f972fc922 to your computer and use it in GitHub Desktop.
Save karlpokus/0b39d52d8fcb3b663cd5950f972fc922 to your computer and use it in GitHub Desktop.
Array filter by regex and some weird arguments applied
var matches = ["sun", "clouds", "rain", "hail", "snow"].filter(/./.test, /i/);
@karlpokus
Copy link
Author

Found this awesome snippet above at SO by user @rndme I really want to know how it works but I can't seem to find any contact info on either SO nor github and I'm not allowed to comment on SO. Here's hoping to him seeing this gist 😃

I get the part where you pass regex.test to filter but the second arg /i/ is to be used as this and that's what puzzles me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment