* 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. * * @static * @since 0.1.0 * @memberOf _ * @category Object
(object, path, defaultValue)
| 24247 | * // => 'default' |
| 24248 | */ |
| 24249 | function result(object, path, defaultValue) { |
| 24250 | path = castPath(path, object); |
| 24251 | |
| 24252 | var index = -1, |
| 24253 | length = path.length; |
| 24254 | |
| 24255 | // Ensure the loop is entered when path is empty. |
| 24256 | if (!length) { |
| 24257 | length = 1; |
| 24258 | object = undefined; |
| 24259 | } |
| 24260 | while (++index < length) { |
| 24261 | var value = object == null ? undefined : object[toKey(path[index])]; |
| 24262 | if (value === undefined) { |
| 24263 | index = length; |
| 24264 | value = defaultValue; |
| 24265 | } |
| 24266 | object = isFunction(value) ? value.call(object) : value; |
| 24267 | } |
| 24268 | return object; |
| 24269 | } |
| 24270 | |
| 24271 | /** |
| 24272 | * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, |
no test coverage detected