JSFiddle - React, Tailwind, and code Playground
JavaScript
var Foo = function () {
var bar;
return {
getBar: function () {
return bar;
},
setBar: function (b) {
bar = b;
}
};
};
var foo1 = new Foo();
foo1.setBar(123123);
alert(foo1.getBar()); // alerts '3', OK
var foo2 = new Foo();
foo2.setBar(4);
alert(foo2.getBar()); // alerts '4', OK
alert(foo1.getBar()); // alerts '4', NOT OK!