mko
mko

Reputation: 22064

How to use object '_' in underscore.js

I'm new to nodejs, the only way that I can come up with is :

var a = require ('./undercore-min')

and make use of underscore object

a([1,2,3]).each(function(a){console.log a})

but I'd love to use the elegant '_' syntax,

_([1,2,3]).each()

how to do that, and how to make underscore globally?

Upvotes: 1

Views: 405

Answers (1)

BNL
BNL

Reputation: 7133

Just assign it.

var _ = require ('./undercore-min')

Upvotes: 3

Related Questions