Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jaibatrik's full-sized avatar
🏃‍♂️
Trying to login as frequently as I can

Jaibatrik Dutta jaibatrik

🏃‍♂️
Trying to login as frequently as I can
View GitHub Profile
@jaibatrik
jaibatrik / trace-property-access.js
Last active July 10, 2020 12:41
Trace property access in nested JavaScript objects
const tracePropertyAccess = (obj, handler, path) => {
path = path || [];
return new Proxy(obj, {
get(target, propKey, receiver) {
const val = Reflect.get(target, propKey, receiver),
newPath = path.concat(propKey);
if (val && typeof val === 'object') {
return tracePropertyAccess(val, handler, newPath);