Skip to main content

result

_.result(path, object) # Ⓢ [Ⓣ][1] Ⓝ

This method is like _.get except that if the resolved value is a



function it's invoked with the this binding of its parent object and



its result is returned.

Since​

0.1.0

Arguments​

  1. path (Array|string): The path of the property to resolve.
  2. object (Object): The object to query.

Returns​

(*): Returns the resolved value.

Example​

var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };

_.result('a[0].b.c1', object);
// => 3

_.result('a[0].b.c2', object);
// => 4

_.result(['a[0].b.c3', 'default'], object);
// => 'default'

_.result(['a[0].b.c3', _.constant('default')], object);
// => 'default'