Skip to content

Instantly share code, notes, and snippets.

@rjoydip-zz
Last active February 24, 2017 07:09
Show Gist options
  • Save rjoydip-zz/3ac345d47608e7aa264f9f9bd87d7fb4 to your computer and use it in GitHub Desktop.
Save rjoydip-zz/3ac345d47608e7aa264f9f9bd87d7fb4 to your computer and use it in GitHub Desktop.
This work on object layer one
function traversObj(){
var args = Array.prototype.slice.call(arguments);
(args.length > 0) ? (typeof args[0] == 'object' && typeof args[1] == 'function') ? traverseObjFn(args[0],args[1]) : 'Arguments are incorrect' : 'Incorrect function arguments';
}
function isObject(obj){
return (typeof obj === 'object') ? true : false;
}
function isNestedObject(obj,callback){
var _obj = obj;
Object.keys(_obj).forEach(function(item,index){
(_obj[item] != '' && _obj[item] != undefined) ? callback(null,isObject(_obj[item])) : callback(item + ' has no values',null);
});
}
/*
var myObj = {
id: 1,
name: 'joy',
address : {
street : 'abc'
}
};
isNestedObject(myObj,function (err,data){
(err) ? console.log(err) : console.log(data);
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment