Default is working wrong for nested null value
Closed this issue · 0 comments
vladshcherbin commented
import delve from 'dlv'
let obj = {
a: {
c: 1,
d: undefined,
e: null
}
}
console.log(delve(obj, 'a.c', 'default')) // 1
console.log(delve(obj, 'a.c.f', 'default')) // default
console.log(delve(obj, 'a.d', 'default')) // default
console.log(delve(obj, 'a.d.f', 'default')) // default
console.log(delve(obj, 'a.e', 'default')) // null
console.log(delve(obj, 'a.e.f', 'default')) // null <- bug
The last one is nested key over null
value, it doesn't exist but returns null
instead of default value.