var obj = {
get name() {
return "Name";
}
};
var obj = {};
Object.defineProperty(obj, "name", {
get: function() {
return "Name";
}
});
function Foo() {
let counter = 0;
Object.defineProperty(this, "counter", {
get() {
return counter++;
}
})
}
const foo = new Foo();
foo.counter; // => 0
foo.counter; // => 1