Is it possible to do the same as in Java and pass a function reference to a function of a particular object in javascript?
Consider the following code:
_.every(aS, function (value) {
return exp.test(value);
});
I would like to do:
_.every(aS, exp.test);
I.e. cause the test
function of that particular RegExp
to be called.
Is this possible in javascript?
Answer: Yes it is possible, take a look at chapter 2 of You Don't Know JS: this & Object Prototypes section Hard Binding.