Created
June 2, 2015 11:07
-
-
Save eyy/fb6f2f9be143a64a70a6 to your computer and use it in GitHub Desktop.
dot path; dot({ prop: { inner: 1 } }, 'prop.inner') == 1
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
| // dot path; dot({ prop: { inner: 1 } }, 'prop.inner') == 1 | |
| function dot (o, path) { | |
| if (!path) | |
| return o | |
| var p = path.split('.') | |
| while (p.length > 0) { | |
| o = o[p.shift()] | |
| if (o == undefined) | |
| break | |
| } | |
| return o | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment