class cls {
str= 'hello';
}
对比
class cls {
str: string;
constructor() {
this.str = 'hello';
}
}
这两种形式有什么区别?
空无一人。这:
class Foo {
str = 'hello';
}
class Bar {
str: string;
constructor() {
this.str = 'hello';
}
}
将导致以下输出:
var Foo = (function () {
function Foo() {
this.str = 'hello';
}
return Foo;
}());
var Bar = (function () {
function Bar() {
this.str = 'hello';
}
return Bar;
}());
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句