1function dotify(obj) {
2 const res = {};
3 function recurse(obj, current) {
4 for (const key in obj) {
5 const value = obj[key];
6 if(value != undefined) {
7 const newKey = (current ? current + '.' + key : key);
8 if (value && typeof value === 'object') {
9 recurse(value, newKey);
10 } else {
11 res[newKey] = value;
12 }
13 }
14 }
15 }
16 recurse(obj);
17 return res;
18}
19dotify({'a':{'b1':{'c':1},'b2':{'c':1}}}) //{'a.b1.c':1,'a.b2.c':1}