index.js
function Foo() {
const list = [];
this.push = function (val) {
list.push(val);
};
this.getList = function () {
console.log(list);
};
}
const foo1 = new Foo();
const foo2 = new Foo();
foo1.push(1);
foo1.getList(); // [ 1 ]
foo2.getList(); // []