We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3212139 commit 97e7f1bCopy full SHA for 97e7f1b
index.js
@@ -1,7 +1,7 @@
1
-export default function dlv(obj, key, def, p, undef) {
+export default function dlv(obj, key, def, undef) {
2
key = key.split ? key.split('.') : key;
3
- for (p = 0; p < key.length; p++) {
4
- obj = obj ? obj[key[p]] : undef;
5
- }
+ obj = key.reduce(function(obj, p) {
+ return obj ? obj[p] : undef;
+ }, obj);
6
return obj === undef ? def : obj;
7
}
0 commit comments