In the context of underscore.js:
// Create a safe reference to the Underscore object for use below.
var _ = function(obj) { return new wrapper(obj); };
Simply put, what does this function return?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is a wrapper function for the
wrapperconstructor to allow you using underscore without thenewkeyword. Calling underscore will always return a newwrapperinstance.Btw, the
wrapperfunction has been removed in this commit. The_function itself is the constructor now, see Understanding the declaration of the underscore in _.js? for explanation.