I am new to object oriented javascript, hence this question can be very naive.
I have:
RIT.test = (function() {
test.prototype.SRT = {
someInSRT: 5
};
function test() {
}
return test;
})();
And I am doing the following:
var v1 = new RIT.test();
var v2 = new RIT.test();
v1.SRT.someInSRT = 10;
v1.SRT.someInSRT = 5;
console.log(v1.SRT.someInSRT);
console.log(v2.SRT.someInSRT);
Why is the value of both v1.SRT.someInSRT and v2.SRT.someInSRT both 5? I imagined that I am creating two separate instances with 'new'.
Can someone suggest me a better approach please? FYI, SRT must be an object.