javascript - How do I mix underscore functions to use a custom comparison algorithm for _.contains()? -


Ideally, I want to pass a custom comparison function to _. Logic, but it only accepts collection and one value.

Code

I want to do this:

 _.contains (['apple', 'orange'], ' Sepales', function (element, value) {new rexpacks (element) test (value);});  

... but if I can not, what's the best thing?

It looks as if you are looking, what if true returns Passes at least one element in the test array:

  _. Some (['apple' '' oranges'], function (element) {new replay (element) test ('selection');});   

You can easily wrap it in your function:

  function test_regexes (arr, value) {return_.some (arr, function) {New RegExp (element) .test (value);}); } test_regexes (['apple', 'orange'], 'sepalesh');    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -