为什么命名为“下划线"或"lodash"? [英] Why the name 'underscore' or 'lodash'?

查看:187
本文介绍了为什么命名为“下划线"或"lodash"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么这些库以_命名?

Why are these libraries named after _ ?

它背后是否有某些意义,或者原因是只是因为我们可以做到" ?

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

据我所知,下划线 lodash 做了很多类似的事情.另外,两个名称都指向 _

As far as i know, underscore and lodash do a lot of similar stuff. Also, both the names point to _

即使它们的变量名是 _

那么 _ 与这些库的工作是否存在某种关系?还是它的名字?

So is there some relation of _ with the working of these libraries? Or its just a name?

推荐答案

Lodash

根据我对两者历史的了解,lodash旨在代替下划线.因此,lodash实际上是下划线上的单词的演奏-低破折号",当破折号-稍微低一点时,它看起来像什么? _为什么,当然是下划线

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

因此,它尽可能涵盖了lodash的所有内容.

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

Undercore的起源仅是一个猜测-但我会做出一个猜测.

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

Java的回到黄金时代",当强大的JQuery统治至高无上时,小型(当时)实用程序库开始兴起-但是我们当时没有(或者不是很好)一件事已知)是用于导入的简单结构,并且需要外部库.

"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.

非常像JQuery将其所有功能分组在一个巨型$对象下-下划线(我想)也希望如此.为什么?为了简洁起见,这可能是33t的因素.尤其是在大多数人只在页脚中包含一堆脚本标签的时代.如果您正在查看实用程序库的主页,那么对您而言更具吸引力的是:<​​/p>

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:

标识符必须以$,_或Unicode中的任何字符开头 类别大写字母(Lu)",小写字母(Ll)", "Titlecase字母(Lt)",修饰语字母(Lm)",其他字母(Lo)", 或信函编号(Nl)".

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

这篇关于为什么命名为“下划线"或"lodash"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆