Reputation: 539
Can it be done?
I have the following:
populate.func = function(node, state) {
return (new function(data) { /* stuff*/ });
}
However, calling populate.func invariably calls both the called function and the returned function, whether I use regular calling convention or the call method. I want to be able to call populate.func and just return the function as a value to make use of, without actually running it...
Upvotes: 0
Views: 349
Reputation: 20180
just do this
populate.func = function(node, state) {
return (function(data) { /* stuff*/ });
}
Your code is instantiating a new object using your function as a constructor function, but you want to return a reference to your function instead, so just drop the new keyword.
Upvotes: 1
Reputation: 7590
I'm not even sure what your code is actually doing, but I think what you want is:
populate.func = function(node, state) {
return function(data) { /* stuff*/ };
}
Upvotes: 0