Skip to content

Instantly share code, notes, and snippets.

View dijs's full-sized avatar
🏠
Working from home

Richard van der Dys dijs

🏠
Working from home
View GitHub Profile
@dijs
dijs / get.js
Created April 16, 2017 08:16
Get implementation
function get(obj, path, def) {
const parts = path.split('.');
const [first,] = parts;
const value = obj[first];
if (parts.length === 1) {
return value || def;
}
return get(value, parts.slice(1).join('.'), def);
}

Keybase proof

I hereby claim:

  • I am dijs on github.
  • I am dijs (https://keybase.io/dijs) on keybase.
  • I have a public key ASAwfYz8pR__vxK7rmaK-yFUWJFuB11izKq98hOv6ZDjJwo

To claim this, I am signing this object: