Last active
February 7, 2016 21:29
-
-
Save gmmorris/7d45ffcc3d97289eecb2 to your computer and use it in GitHub Desktop.
Helper functions for the Safe Access Proxy article
This file contains hidden or 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
| const isObject = obj => obj && typeof obj === 'object'; | |
| const hasKey = (obj, key) => key in obj; | |
| const Undefined = new Proxy({}, { | |
| get: function(target, name){ | |
| return Undefined; | |
| } | |
| }); | |
| const either = (val,fallback) => (val === Undefined? fallback : val); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment