Why the name 'underscore' or 'lodash'?

后端 未结 1 568
轮回少年
轮回少年 2021-02-14 20:13

Why are these libraries named after _ ?

Is there some significance behind it or the reason is \"Just because we can\"?

As far as i know,

1条回答
  •  情深已故
    2021-02-14 20:23

    Lodash

    From my understanding of the history of the two, lodash was meant as a lightweight replacement for underscore. So lodash is effectively a play on words on underscore - "low dash", what does a dash - look like when its a bit lower to the ground? _ Why, an underscore of course

    So that covers lodash in as much detail as it warrants.

    Underscore

    Underscore's origin would only be a guess - but a guess I shall make.

    "Back in the golden days" of Javascript, when the mighty JQuery reigned supreme, small (at the time) utility libraries started emerging - but one thing we didn't have at the time (or wasn't well known) was simple constructs for import and requiring external libraries.

    Very much like JQuery grouping all of its functionality under one giant $ object - underscore (I am guessing) wanted the same. Why? Probably for brevity and that l33t factor. Especially in the days where most people were just including a bunch of script tags in the footer. If you were looking at utility library home page, what appeals to you more:

    // totes l33t
    _.map(a, function(e) { ... }
    
    // pfft, no thanks grandpa
    underscore.map(a, function(e) { ... }
    

    But why _. Well after $ its one of few cool short names left:

    An identifier must start with $, _, or any character in the Unicode categories “Uppercase letter (Lu)”, “Lowercase letter (Ll)”, “Titlecase letter (Lt)”, “Modifier letter (Lm)”, “Other letter (Lo)”, or “Letter number (Nl)”.

    https://mathiasbynens.be/notes/javascript-identifiers

    0 讨论(0)
提交回复
热议问题