人们为什么称jQuery $别名为“工厂"? [英] Why do people call the jQuery $ alias a 'factory'?

查看:83
本文介绍了人们为什么称jQuery $别名为“工厂"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在各种站点上,jQuery的$变量称为别名,在其他站点上,其称为工厂.我看了一下源代码,我认为前者是正确的.据我所知,这里定义了美元符号:

// Expose jQuery to the global object
return (window.jQuery = window.$ = jQuery);

这会将$jQuery都设置为SAME别名; jQuery对象没有工厂".网站将$称为工厂"是否完全错误?

解决方案

我认为其中任一个都可以.美元符号当然是jQuery函数的别名,专门用作速记.如果有人将函数称为工厂,我认为这并不是$别名所特有的,而只是描述jQuery函数的一般功能,即使用各种不同类型的输入创建对象.

On various sites, jQuery's $ variable is referred to as an alias, and on others, it is referred to as a factory. I took a look at the source code, and I think the former is correct. As far as I can see, the dollar symbol is being defined here:

// Expose jQuery to the global object
return (window.jQuery = window.$ = jQuery);

This is setting both $ and jQuery to the SAME alias; there is no 'factory' for jQuery objects. Are the sites referring to $ as a 'factory' simply wrong?

解决方案

I think either is an okay term. The dollar sign is certainly an alias for the jQuery function, specifically to be used as a shorthand. If someone refers to the function as a factory, I don't think that's specific to the $ alias, but just describing what the jQuery function does in general, which is create objects from various different types of input.

这篇关于人们为什么称jQuery $别名为“工厂"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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