KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Given a JavaScript array of objects, how can I get the key and value of each object? The code below shows what I'd like to do, but obviously doesn't work: var top_brands = [ { 'Adidas' : 100 }, { 'Nike' : 50 }]; var brand_options = $("#top-brands"); $.each(top_brands, function() { brand_options.append($("<option />").val(this.key).text(this.key + " " + this.value)); }); So, how can I get this.key and this.value for each entry in the array?
Tags (comma-separated)
Save Edits
Cancel