Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are Javascript libraries like LoDash or UnderScore utilized more often than raw JS functions like map, reduce, or filter [closed]

I tend to find the listed libraries utilized more often when straight JS functions would have done the job. I would believe that loading additional libraries would always add more load time, so I am curious as to why raw JS functions are not used more often.

Are there any speed advantages to just pure JS functions in the language over post-written helper functions?

Wouldn't the benefit of the pre-made library be lost on the additional library load times?

like image 925
SoEzPz Avatar asked Feb 09 '23 16:02

SoEzPz


1 Answers

Usually the use of a framework over raw JS is the compatibility. There are differences in Javascript between browsers, between different versions of browsers, and some implementations are incomplete. A tool like underscore and the like helps to smoothen out problems with compatibility providing a common layer between your code and raw JS.

If you can eliminate the possiblity of having different browsers then sure, go ahead and do Raw JS, but in the long run you save yourself the extra hassle down the road.

like image 90
MiltoxBeyond Avatar answered Feb 12 '23 10:02

MiltoxBeyond