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'),Written by Asa Ayers
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Underscorejs
Authors
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
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#