mirror of
https://github.com/alrayyes/wiki.git
synced 2024-12-01 15:26:23 +00:00
313 B
313 B
id | title |
---|---|
94a1d579-bd29-42f0-a6c6-2aa0700703d4 | JavaScript object getters & setters |
Example
const obj = {
get foo() {
console.log('GET foo');
return 123;
},
set bar(value) {
console.log('SET bar to '+value);
}
};
obj.foo
obj.bar = 'tralala'