Hello fellow JavaScripters.
I have recently started to mess around with the stampit.js library as a way of studying different inheritance methods in JavaScript.
My question is in regards to my state
objects (there are two in my example), each state object is being assigned a different value ("first" and "second"), but my first state object seems to want to copy the value from my second state object, which, as far as I understand, is not the behavior I should expect from stampit.js. Shouldn't my state objects be unique when passed through stamp.create()
?
Here is my example:
var stamp = require('stampit')();
var state = { x: { y : null } };
state.x.y = "first";
var example1 = stamp.create(state);
state.x.y = "second";
var example2 = stamp.create(state);
// These are the same, but shouldn't they be different?
console.log(example1.a.b); // prints "second"
console.log(example2.a.b); // prints "second"
So what am I missing here?