Skip to content

Instantly share code, notes, and snippets.

@maksim-tolo
Forked from prashantpalikhe/traceProperty.js
Created April 4, 2019 15:41
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 maksim-tolo/ef8e1940f37c9c323e9d83c62d6d4983 to your computer and use it in GitHub Desktop.
Save maksim-tolo/ef8e1940f37c9c323e9d83c62d6d4983 to your computer and use it in GitHub Desktop.
Devtools snippet to trace property access
const traceProperty = (object, property) => {
let value = object[property];
Object.defineProperty(object, property, {
get () {
console.trace(`${property} requested`);
return value;
},
set (newValue) {
console.trace(`setting ${property} to `, newValue);
value = newValue;
},
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment