http://jsperf.com/immutable-vs-mutable
Safari 和 Firefox 均符合預期,二者性能相差無幾
var VectorMutable = function(x, y) { this.x = x; this.y = y; };
var Vector = function(x, y) { this.x = x; this.y = y; };
VectorMutable.prototype.clone = function() { return new VectorMutable(this.x, this.y); };
VectorMutable.prototype.add = function(x, y) { this.x += x; this.y += y; return this; };
Vector.prototype.add = function(x, y) { return new Vector(this.x+x, this.y+y); };
var result1 = new VectorMutable(0,0).clone().add(1,2);
var result2 = new Vector(0,0).add(1,2);
猜測是 chrome 對克隆對象的額外優化所致
走同样的路,发现不同的人生