Created
July 15, 2020 14:23
-
-
Save rjcorwin/ddf836d7b0bfaf1b5ca63400f4dca388 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const language = { | |
_numberOfTimesCalled: 0, | |
set foo(name) { | |
this._numberOfTimesCalled++ | |
this._foo = name | |
}, | |
get foo() { | |
return this._foo | |
} | |
}; | |
language.foo = { | |
name: 'R.J.' | |
} | |
language.foo.name = 'Evans' | |
// Will log Evans. | |
console.log(language.foo.name) | |
// Will log 1, not 2. | |
console.log(language._numberOfTimesCalled) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment