Lodash. vs _. difference


#1

I am trimming an array this way using lodash

var data_parts = lodash._.map(strData.split("|"), lodash._.trim);

but I don’t see the lodash. prefix in most examples that I see on websites. They almost all just use _.map

Any clarification why I need to use lodash._.map whereas examples on lodash website just uses _.map


#2

Hi m_menon,

I think its because you need to load (using require()) the library.
DF 1.5 intro service side scripts (and lodash), as you can see here, at this time, you dont need any prefix.
But in DF 2.0.3 they remove the loading of lodash by default, as you can see here, so, now you need to use require() to load lodash, and require() must to create an object with the evaluated script content… AFAIK. :slight_smile:

Cheers!


#3

hi Anderson,

Cool thanks a ton for the explanation :relieved:. I just wanted to make sure that I fully understand the code that I write. Everywhere on the net, the snippets and samples were all _.method instead of lodash._.method (which I followed), which left me confused.

Cheers,
M.M