3 ms·
I think this kind of access pattern is typically a code smell. Instead of carrying around arbitrarily nested values you should try to normalize it into a known
by TheAceOfHearts 9y ago
I think this kind of access pattern is typically a code smell. Instead of carrying around arbitrarily nested values you should try to normalize it into a known and consistent shape when crossing serialization boundaries.
Proxy pays a big performance penalty, and I doubt it'll be improving any time soon. In addition, I believe it's not possible to polyfill Proxy. An alternative could be to just wrap the deep property access in a try/catch:
function getQux (input) {
try {
return input.foo.bar.baz.qux()
} catch (e) {
return null
}
}
- deleted 9y ago[deleted]
- slmgc 9y agoWrapping you code into a try/catch block decreases performance even more, you don't want to do that. You might want to check it out: https://github.com/GoogleChrome/proxy-polyfill https://github.com/GoogleChrome/proxy-polyfill
- afranchuk 9y agoYeah, my first thought when seeing that it uses Symbol and Proxy was that Proxy can't be polyfilled. But it looks like there's partial polyfills for it: https://www.google.com/url?sa=t&source=web&rct=j&url=https://github.com/GoogleChrome/proxy-polyfill&ved=2ahUKEwjVptCr5ZfaAhURjlkKHe1MB9sQFjAAegQIBxAB&usg=AOvVaw0nUHNMpcd0EoEqYO_Csr4A https://www.google.com/url?sa=t&source=web&rct=j&url=https:/...