Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经浏览了 jQuery 源代码,但我找不到 jQuery 如何实现命名空间功能?
命名空间在 JavaScript 中通过使用函数范围和对象来处理。
jQuery 默认公开两个全局变量:jQuery和$.
jQuery
$
你可以做类似的...
(function(global) { global.someGlobalIdentifier = { // Whatever you want... }; })(this);