I'm trying to create a property within a prototype so it will be available in all instances (can't put it in the constructor and would prefer to not create it via instance.propertyname = *; if at all possible. As an example the code below:
function A() {
}
A.prototype.constructor = A;
Object.defineProperty(A.prototype, 'B', {
writable: true,
enumerable: true,
value: null
});
var a = new A();
a.B = 'test';
var b = new A();
var c = new A();
b.B = '2';
console.log(a,b,c);
Produces the output:
A {B: "test", B: null} A {B: "2", B: null} A {B: null}
How do I get it to instead produce:
A {B: "test"} A {B: "2"} A {B: null}