3
我在做這樣的事情:任何獲得級聯中最後一個方法返回值的方法?
new A()
..methodA()
..methodB()
.toString();
如果這種返回toString()
的結果呢?目前它返回新的A
對象。
我在做這樣的事情:任何獲得級聯中最後一個方法返回值的方法?
new A()
..methodA()
..methodB()
.toString();
如果這種返回toString()
的結果呢?目前它返回新的A
對象。
在您的代碼toString()
適用於methodB()
的結果。這就像你正在做的:
var func = (o) {
o.methodA();
o.methodB().toString();
return o;
};
func(new A());
做你想做什麼,你必須做一些事情,如:
(new A()
..methodA()
..methodB()).toString();