js-tetris - proxy
This file contains 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
let accountValues = { | |
score: 0, | |
lines: 0 | |
} | |
function updateAccount(key, value) { | |
let element = document.getElementById(key); | |
if (element) { | |
element.textContent = value; | |
} | |
} | |
let account = new Proxy(accountValues, { | |
set: (target, key, value) => { | |
target[key] = value; | |
updateAccount(key, value); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment