Loading problemβ¦
Implement a get(object, path, defaultValue) function similar to Lodash's _.get().
It safely accesses deeply nested properties without throwing errors when intermediate values are null or undefined.
path can be a string like 'a.b.c' or 'a[0].b'path can also be an array like ['a', 'b', 'c']defaultValue if the resolved value is undefined'a.b.c' β keys ['a', 'b', 'c']'a[0].b' β keys ['a', '0', 'b']'a.b[0].c' β keys ['a', 'b', '0', 'c']['a', '0', 'b'] β keys used directlynull or undefined as the object β return defaultValuenull in the path β return defaultValue (can't traverse further)null β return null (not the default)undefined β return defaultValue0, false, '' β return the value (not the default)