Skip to content

Instantly share code, notes, and snippets.

@melvinodsa
Last active November 23, 2018 04:36
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 melvinodsa/5ed9da6ccba3f5b653836fca642c76a0 to your computer and use it in GitHub Desktop.
Save melvinodsa/5ed9da6ccba3f5b653836fca642c76a0 to your computer and use it in GitHub Desktop.
function insurance(obj) {
return new Proxy(obj, {
get(target, key) {
const accessedProperty = Reflect.get(target, key);
if (typeof accessedProperty === 'object') {
return insurance(accessedProperty);
} else {
return accessedProperty == undefined ?
Undefined:
accessedProperty;
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment