mirror of
https://github.com/alrayyes/wiki.git
synced 2025-07-24 09:49:34 +00:00
Quartz sync: May 6, 2024, 10:40 PM
This commit is contained in:
parent
aee9145691
commit
4ef8371441
635 changed files with 22281 additions and 6 deletions
21
content/20201007093418-javascript_object_getters_setters.md
Normal file
21
content/20201007093418-javascript_object_getters_setters.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
id: 94a1d579-bd29-42f0-a6c6-2aa0700703d4
|
||||
title: JavaScript object getters & setters
|
||||
---
|
||||
|
||||
# Example
|
||||
|
||||
``` javascript
|
||||
const obj = {
|
||||
get foo() {
|
||||
console.log('GET foo');
|
||||
return 123;
|
||||
},
|
||||
set bar(value) {
|
||||
console.log('SET bar to '+value);
|
||||
}
|
||||
};
|
||||
|
||||
obj.foo
|
||||
obj.bar = 'tralala'
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue