javascript - What is the underscore function for? -


i've been using underscore collection of statics.

what underscore function for:

var _ = function(obj) {     if (obj instanceof _) return obj;     if (!(this instanceof _)) return new _(obj);     this._wrapped = obj;   }; 

what example of how use this?

you can use underscore wrapper function, more oop-like style:

_(val).method(…); // instead of equal _.method(val, …); 

these wrapper objects allow chaining:

_.chain(val).method1(…).method2(…); // or _(val).chain().method1(…).method2(…); 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -