不确定这种 jQuery/Javascript 编程风格。
我想为我的博客/作品集网站做一个教程,我意识到...尽管我对 jQuery/Javascript 编程的这种特殊方法有所了解,但我不知道如何称呼它或其他人如何称呼它。我知道它是 OOP 的一种特殊方法,向我展示如何执行此操作的人将其称为“原型设计”。但是当我在谷歌上搜索它时,我没有找到类似的东西。这是一个浓缩的例子:
jQuery().ready(function() {
site.internal.page = function () {
return {
init: function () {
var that = this;
},
business: function () {
return {
init: function () {
},
doSomething: function () {
},
addSomething: function (r) {
},
makeSomethign: function () {
}
}
}(),
invoice: function () {
return {
init: function () {
that = this;
},
addItem: function (row) {
}
}
}()
}
}();
site.internal.page.init();
});
任何人都可以帮助我弄清楚如何称呼它。我不确定它是否与制作库或插件相同,但我真的很想弄清楚。谢谢。
Im wanting to do a tutorial for my blog/portfolio site and I realized that... For all I know about this particular method of jQuery/Javascript programming, I do not know what to call it or what other people call it. I know its a particular method of OOP and the person who showed me how to do this referred to it as "Prototyping". But when searching for it on google, im not finding anything similar. Here is condensed example:
jQuery().ready(function() {
site.internal.page = function () {
return {
init: function () {
var that = this;
},
business: function () {
return {
init: function () {
},
doSomething: function () {
},
addSomething: function (r) {
},
makeSomethign: function () {
}
}
}(),
invoice: function () {
return {
init: function () {
that = this;
},
addItem: function (row) {
}
}
}()
}
}();
site.internal.page.init();
});
Can anyone assist me in figuring out what to refer to this as. Im not sure if its the same as making a library or a plug-in, but id really like to figure it out. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在创建匿名函数并将对每个函数的引用存储在变量中。
You are creating anonymous functions and storing a reference to each in a variable.
如果参考
site.internal.page
部分,我建议这是在大型站点中命名 javascript 的尝试。If refereing to the
site.internal.page
part, I would suggest this is an attempt to namespace the javascript in a large site.