Skip to content

Instantly share code, notes, and snippets.

kevinkindom / Object Flatten
Created January 24, 2018 12:18 — forked from penguinboy/Object Flatten
Flatten javascript objects into a single-depth object
View Object Flatten
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;