Skip to content

Instantly share code, notes, and snippets.

@johnryan1982
Created July 12, 2012 22:30
Show Gist options
  • Save johnryan1982/3101506 to your computer and use it in GitHub Desktop.
Save johnryan1982/3101506 to your computer and use it in GitHub Desktop.
Quick and dirty JS Object iterator
function iterate( data )
{
if( typeof data === typeof {} )
{
for( i in data )
{
if( data.hasOwnProperty( i ) )
{
console.log( i, data[i] );
iterate( data[i] );
}
}
}
}
obj = { user: { name:'john', id:30 } }
iterate( obj );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment