Created
October 17, 2018 02:59
-
-
Save azami/379e5ab4f23ed206e625e18358fa687c to your computer and use it in GitHub Desktop.
JavascriptのObjectを.つなぎで指定して値を取得する
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 keys = 'bar.baz'.split('.'); | |
const foo = {foo: {bar: {baz: 123}}}; | |
keys.reduce(((acc, cur) => acc[cur]), foo.foo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment