I have a problem when I instantiate a class 2 times. The 2nd instance keep parameters of the first only if the objects.
Here is a simple example:
var Test = function() {};
Test.prototype = {
bonjour: null,
hello: {
hum: null,
ya: null,
},
};
var testA = new Test();
testA.bonjour = 'Aaa';
testA.hello.hum = 'Bbb';
// return "Aaa"
console.log(testA.bonjour);
// return "{ hum: 'Bbb', ya: null }"
console.log(testA.hello);
console.log('');
var testB = new Test();
// return "null" -> ok
console.log(testB.bonjour);
// return "{ hum: 'Bbb', ya: null }" -> wtf ?!
console.log(testB.hello);
Does anyone have any idea why? Thank you.