Ensure functions can be used as default values for _.result.

This commit is contained in:
John-David Dalton
2014-02-04 23:50:37 -08:00
parent 8498f12a9d
commit de7409fd07
2 changed files with 21 additions and 9 deletions

View File

@@ -7338,10 +7338,10 @@
* // => 'slate'
*/
function result(object, key, defaultValue) {
if (object == null) {
if (object == null || typeof object[key] == 'undefined') {
return defaultValue;
}
var value = typeof object[key] != 'undefined' ? object[key] : defaultValue;
var value = object[key];
return isFunction(value) ? object[key]() : value;
}