Skip to content

Instantly share code, notes, and snippets.

@eyy
Created June 2, 2015 11:07
Show Gist options
  • Select an option

  • Save eyy/fb6f2f9be143a64a70a6 to your computer and use it in GitHub Desktop.

Select an option

Save eyy/fb6f2f9be143a64a70a6 to your computer and use it in GitHub Desktop.
dot path; dot({ prop: { inner: 1 } }, 'prop.inner') == 1
// 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