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

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -