Created
November 16, 2015 19:05
-
-
Save philsinatra/d1cb4ce9ad3aba94b501 to your computer and use it in GitHub Desktop.
Loop Through A JS Obect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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