JSFiddle - React, Tailwind, and code Playground
JavaScript
var A = {
listeners: {},
count: 0,
that:this,
add: function (name){
this.listeners = {};
this.listeners[name] = name;
},
plus: function() {
this.count++;
}
};
function info(value) {
console.log('---- ' + value + ' ----');
console.log('a.listeners: ', a.listeners);
console.log('b.listeners: ', b.listeners);
console.log('a.count: ', a.count);
console.log('b.count: ', b.count)
console.log('------------------');
}
var a = Object.create(A);
var b = Object.create(A);
info('BEFORE');
a.add("aaa");
a.plus();
info('AFTER');