What is the underscore function for?

后端 未结 2 817
小蘑菇
小蘑菇 2020-12-11 10:09

I\'ve been using underscore as a collection of statics.

What is the underscore function for:

var _ = function(obj) {
    if (obj instanceof _) return         


        
2条回答
  •  天涯浪人
    2020-12-11 10:51

    You wrap objects with it:

    _([1, 2, 3, 4]);
    

    And then use Underscore functions on the wrapped object:

    _([1, 2, 3, 4]).shuffle()
    

提交回复
热议问题