Skip to content

Instantly share code, notes, and snippets.

@kevinkindom
kevinkindom / Object Flatten
Created Jan 24, 2018 — 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;