diff --git a/src/index.js b/src/index.js index e46f5b4..ade2de8 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,6 @@ export default function (obj, keys, val) { var i=0, l=keys.length, t=obj, x; for (; i < l; ++i) { x = t[keys[i]]; - t = t[keys[i]] = (i === l - 1 ? val : (x == null ? (+keys[i + 1] > -1 ? [] : {}) : x)); + t = t[keys[i]] = (i === l - 1 ? val : (x != null ? x : (!!~keys[i+1].indexOf('.') || !(+keys[i+1] > -1)) ? {} : [])); } }