I'm filtering an array, and found a regex on here. I'm trying to understand this:

filterArray.filter(/./.test.bind(new RegExp(key, 'g')))

But I don't understand how the array tests it value against the regex or why you have to start with /./ instead of just writing the regex. And how does bind work in this case?

EDIT: Key is just a string that I want to match, "hi" or "dog" or "anything really".

Edit
Report