Is there a way to have a string field in a class shared among all instances instead of creating a new instance for each one?
class A {
a = 'hello'
b() { return this.a;}
}
// This code snippet transpiles into an assignment in the constructor
var A = (function () {
function A() {
this.a = 'hello';
}
A.prototype.b = function () { return this.a; };
return A;
}());
// Is it possible to place the string on the prototype like functions?
// Avoid creating multiple instances of the string
var A = (function () {
function A() {}
A.prototype.b = function () { return this.a; };
A.prototype.a = 'hello';
return A;
}());