有什么区别如下:
function test(){
this.init=function(){//do something}
this.some=function(){//do something}
function other(){}
}
Run Code Online (Sandbox Code Playgroud)
和
function test(){
function init(){//do something}
function some(){//do something}
function other(){}
return {'init':init, 'some':some};
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的解释.
第一个例子:
var object = new test();
object.init();
Run Code Online (Sandbox Code Playgroud)
第二个例子:
var object = text(); // no new
object.init();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
213 次 |
| 最近记录: |