Last Updated: February 25, 2016
·
716
· asaayers

Use _.bind() for simple callbacks.

Need to create a callback that simply calls another function?

var callback = function() { 
    return model.get('comment');
} 

The following code gives you the same result:

var callback = _.bind(model.get, model, 'comment'),

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside