研究一个我发现以下构建的JavaScript库:
theMethod: function () {
var m1 = new SomeClass();
return function (theParameter) {
this.someMethod();
m1.methodCall(this.someField1);
this.someField2 = 'some value';
}
}()
Run Code Online (Sandbox Code Playgroud)
theMethod的调用方式如下:
c.theMethod(paramValue);
Run Code Online (Sandbox Code Playgroud)
作者想用这个宣言说什么?
为什么不使用这样的声明:
theMethod: function (theParameter) {
var m1 = new SomeClass();
this.someMethod();
m1.methodCall(this.someField1);
this.someField2 = 'some value';
}
Run Code Online (Sandbox Code Playgroud) 只是一个奇怪的问题.我想创建一个可以处理无限"层"的函数?make add(2)(3),add(1)(2)(3)...(10)all works.
有任何想法吗?