Skip to content

Instantly share code, notes, and snippets.

@philsinatra
Created November 16, 2015 19:05
Show Gist options
  • Save philsinatra/d1cb4ce9ad3aba94b501 to your computer and use it in GitHub Desktop.
Save philsinatra/d1cb4ce9ad3aba94b501 to your computer and use it in GitHub Desktop.
Loop Through A JS Obect
var myObj = {
Whatever_Property : [
['one', 'fish'],
['two', 'fish'],
['red', 'fish'],
['blue', 'fish']
],
Some_Other_Property : [
['A Title', 'filename.jpg'],
['Another Title', 'filename2.jpg']
]
};
// Loop through each of the object properties
for (var prop in myObj) {
var item = myObj[prop];
$.each(item, function( key, value ) {
console.log(prop + ': ' + value[0] + ' | ' + value[1]);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment