UnderscoreJS : filter part of string

49 Views Asked by At

I would like to filter data but without giving the whole string.

For example, I have an Array with value:'myString', I would like to filter that even if i just pass 'my' or 'String'.

Any idea ?

1

There are 1 best solutions below

0
On BEST ANSWER
var myArray = ["myString"];
if(myArray[0].IndexOf("my") != -1 || myArray.IndexOf("String") != -1 ) {
    ...
}

I didn't misunderstand the question, did I? Underscore.js wouldn't be required for this, either.