var xuj azazaz adda o_O xuj azazaz adda 222 console log JSON stringify

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
var o = {};
xuj(o, ["azazaz", "adda", "o_O"], 1);
xuj(o, ["azazaz", "adda", "222"], 1);
console.log(JSON.stringify(o));
function xuj(obj, path, value) {
var ref = obj;
for (var i = 0; i < path.length - 1; ++i) {
if (ref[path[i]] === undefined)
ref[path[i]] = {};
ref = ref[path[i]];
}
ref[path[path.length - 1]] = value;
}