我的最终目标是能够像这样做:
MyVar(parameter).functionToPerform();
尽管我已经阅读了有关变量声明的内容,并查看了jQuery代码,可还是无法理解。
到目前为止,这是我尝试过的代码,但它失败了:
var MyClass = function(context) {
this.print = function(){
console.log("Printing");
}
this.move = function(){
console.log(context);
}
};
var test = new MyClass();
test.print(); // Works
console.log('Moving: ' + test('azerty').move() ); // Type property error
test(...)
不同于new test(...)
。 :) - bzlm