deepValue with an empty path returns the object itself

This commit is contained in:
D. Berge
2023-11-13 20:52:33 +01:00
parent 80de0c1bb0
commit 13f68d7314

View File

@@ -215,7 +215,11 @@ function deepValue (obj, path) {
if (obj !== undefined) {
const key = path.shift();
if (!path.length) {
return obj[key];
if (key === undefined) {
return obj;
} else {
return obj[key];
}
} else {
return deepValue(obj[key], path);
}