【发布时间】:2017-10-17 22:54:32
【问题描述】:
这里有两个 javascript sn-ps。我无法理解两者之间的区别。似乎两者都允许更新实例。
var Test1 = (function () {
function Test1(_x, _y) {
this.x = _x;
this.y = _y; console.log("test1");
}
return Test1;
}());
var Test2 = function () {
function Test2(_x, _y) {
this.x = _x;
this.y = _y; console.log("test2");
}
return Test2;
}();
new Test1(1,2);
new Test2(2,4);
编辑:对我来说它看起来一样但是,我正在使用 TypeScript,它生成了像 Type1 这样的类。他们选择这样做一定是有原因的。毕竟最短的代码更好?
谢谢
【问题讨论】:
标签: javascript