Return undefined when the key is not present.

This commit is contained in:
Philip Giuliani
2018-05-30 17:10:38 +02:00
parent 94dc0d176c
commit 6435ced707
9 changed files with 14 additions and 14 deletions

View File

@ -729,8 +729,8 @@ const utils = {
},
// Get a nested value in an object
getDeep(object, value) {
return value.split('.').reduce((obj, key) => obj[key] || {}, object);
getDeep(object, path) {
return path.split('.').reduce((obj, key) => (obj && obj[key]) || undefined, object);
},
// Get the closest value in an array