博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
为什么jQuery要返回jQuery.fn.init对象
阅读量:5747 次
发布时间:2019-06-18

本文共 795 字,大约阅读时间需要 2 分钟。

作者:zccst

jQuery = function( selector, context ) {

// The jQuery object is actually just the init constructor 'enhanced'

return new jQuery.fn.init( selector, context, rootjQuery );

}

 

jQuery.fn = jQuery.prototype = {

……

}

 

jQuery.fn.init.prototype = jQuery.fn;

 

在 stackoverflow 上找到类似问题: 还有这个 

 

I believe the code is written in this fashion so that the new keyword is not required each time you instantiate a new jQuery object and also to delegate the logic behind the object construction to the prototype. The former I believe is to make the library cleaner to use and the latter to keep the initialisation logic cleanly in one place and allow init to be recursively called to construct and return an object that correctly matches the passed arguments.

转载于:https://www.cnblogs.com/zccst/p/3681722.html

你可能感兴趣的文章
开始第一个Python程序!
查看>>
Google 或强制 OEM 预装 20 款应用,给你一个不Root的理由
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
双边过滤器(Bilateral filter)
查看>>
Android图形显示系统——下层显示4:图层合成上(合成原理与3D合成)
查看>>
VirtualBox中的虚拟网络环境设置
查看>>
渗.透流程、HTTP协议
查看>>
move
查看>>
博客链接
查看>>
链接脚本解析
查看>>
Linux环境下git客户端的安装、配置及基本用法
查看>>
centos7部署MongoDB数据库复制集(超详细)
查看>>
linux 内核移植(四)——Makefile和链接脚本分析
查看>>
Linux系统上LVM(逻辑卷)的实现
查看>>
前端代码标准最佳实践:CSS篇
查看>>
Windows 10 技术预览
查看>>
linux常用命令
查看>>
telnet命令
查看>>
linux磁盘管理
查看>>