There are plenty of solutions out there to check/access an object literal giving a string of dot notation, but what I need to do is SET an object literal based on a string o
My version:
function setDepth(obj, path, value) { var tags = path.split("."), len = tags.length - 1; for (var i = 0; i < len; i++) { obj = obj[tags[i]]; } obj[tags[len]] = value; }
Working demo: http://jsfiddle.net/jfriend00/Sxz2z/