【发布时间】:2011-03-28 04:23:23
【问题描述】:
我有一个大的 js 文件,我想将它分成多个命名空间。
与将所有内容都保存在一个命名空间中相比,这是一种好还是坏的方法?
-
在 NAMESPACE_FIRST 中如何调用地图构建?
var NAMESPACE_FIRST = { init:function() { alert("onload functions"); }, this.map:function() { this.length = 0; }, this.map.prototype.build:function(){ return this.length; } }; var NAMESPACE_SECOND = { upload:function() { //do something }, delete:function() { //do something } }; $(function () { NAMESPACE_FIRST.init(); });
【问题讨论】:
标签: javascript prototype namespaces