Awesome.
I would suggest using something like https://github.com/afeld/backbone-nested to enable a.get('foo.bar.foo') so you don't have to a.get('foo').bar.foo and suffer undefined errors.
I would suggest using something like https://github.com/afeld/backbone-nested to enable a.get('foo.bar.foo') so you don't have to a.get('foo').bar.foo and suffer undefined errors.
It shouldn't have to be a library with custom handling of the edge cases like that :|
function get(p, o) {
var parts = p.split('.');
for (var i = 0, l = parts.length; i < l; i++)
if (o.hasOwnProperty(parts[i]))
o = o[parts[i]];
else return undefined;
return o;
}
var o = { a: { b: { c: 1 } } };
console.log(get('a.b.c', o)); // 1
console.log(get('no.way', o)); // undefined
I'd be more likely to reuse something like that because it's already useful in the codebase than bringing on another library.However, I am speaking out of ignorance, as it appears that the library you cite does a lot more than this simple thing: https://github.com/afeld/backbone-nested/blob/master/backbon...
In any case safe lookup methods are very useful!
if(defined jQuery.unknown.propierties)