Javascript 这里的“_”是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5418279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 17:07:30  来源:igfitidea点击:

What does "_" means here?

javascriptbackbone.js

提问by Mellon

I am learning backbone.js, in it's tutorial, it has the following code

我正在学习backbone.js,在它的教程中,它有以下代码

var object = {};
_.extend(object, Backbone.Events);
...

I don't understand the "_" in the code, what does it means? and what is this "extend"? does it has the same meaning as jQuery.extend ?

我不明白代码中的“ _”是什么意思?这个“扩展”是什么?它与 jQuery.extend 具有相同的含义吗?

采纳答案by benvds

It copies all the Backbone.Events properties over to the object. Extend is a method from the underscore library: http://documentcloud.github.com/underscore/#extend

它将所有 Backbone.Events 属性复制到对象。Extend 是下划线库中的一个方法:http: //documentcloud.github.com/underscore/#extend

I'd say it's the same as the jQuery method.

我会说它与jQuery方法相同。

回答by Bruno Rohée

From Backbone's own homepage :

从 Backbone 自己的主页:

Backbone's only hard dependency is Underscore.js.

Backbone 唯一的硬依赖项是 Underscore.js。

_is the object created by Underscore.js, in the same way as $is the jQuery object

_是 Underscore.js 创建的对象,$和 jQuery 对象一样

http://documentcloud.github.com/underscore/#extendas for what _.extenddoes.

http://documentcloud.github.com/underscore/#extend至于是什么_.extend