Last active
November 23, 2018 04:36
-
-
Save melvinodsa/5ed9da6ccba3f5b653836fca642c76a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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