2

How do I used a function I defined somewhere as a callback function. I am trying to pass a named function to lodash:

function boo(value, key) {
  // do something
}

_.forOwn(object, boo(value, key));

This doesn't work, I get value is not defined. What is the right way to do it?

ilyo
  • 33,469
  • 40
  • 99
  • 145

1 Answers1

4

Here, you are invoking the function, not passing a ref boo(value, key)

To pass a ref to the function, just type the name of the function as an argument _.forOwn(object, boo);

posit labs
  • 7,733
  • 4
  • 32
  • 57