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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -