get
get(obj, path)
Parameters
- obj
{Object}
:the object to use as the root for property based navigation
- path
{String}
:a String of dot-separated keys, representing a path of properties
Returns
{*}
:
the value at the property path
A path is a dot-delimited sequence of zero or more property names, such that "foo.bar" means "the property 'bar' of the object at the property 'foo' of the root." An empty path returns the object passed.
var get = require("can-util/js/get/get");
console.log(get({a: {b: {c: "foo"}}}, "a.b.c")); // -> "foo"
console.log(get({a: {}}, "a.b.c")); // -> undefined
console.log(get([{a: {}}, {a: {b: "bar"}}], "a.b")); // -> "bar"