【发布时间】:2010-06-04 19:12:02
【问题描述】:
当您可以通过在第二个代码 sn-p 中直接声明 NS 来完成相同的事情时,以下示例中返回方法的意义何在?
1:
var NS = function() {
return {
method_1 : function() {
// do stuff here
},
method_2 : function() {
// do stuff here
}
};
}();
2:
var NS = {
method_1 : function() { do stuff },
method_2 : function() { do stuff }
};
【问题讨论】:
标签: javascript namespaces