Skip to content

Instantly share code, notes, and snippets.

@Celleb
Created March 11, 2020 09:46
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 Celleb/1e1238e022efa6f0d8bd74af256314d9 to your computer and use it in GitHub Desktop.
Save Celleb/1e1238e022efa6f0d8bd74af256314d9 to your computer and use it in GitHub Desktop.
const defaultColor = 'GREEN';
const colors = {
0: 'RED',
1: 'PINK',
2: 'PURPLE'
};
const scoreColors = new Proxy(colors, {
get: function (obj, prop) {
return obj.hasOwnProperty(prop) ? object[prop] : defaultColor;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment