Skip to content

Instantly share code, notes, and snippets.

@melcor76

melcor76/main.js Secret

Last active November 19, 2019 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melcor76/e36b4768de690a32baedd25dbb6b8633 to your computer and use it in GitHub Desktop.
Save melcor76/e36b4768de690a32baedd25dbb6b8633 to your computer and use it in GitHub Desktop.
js-tetris - proxy
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