I have this object:
question = {
"name":"Foo",
"number":"123",
"options":{"1":"1 - 20","2":"21 - 30","etc":"etc"}
}
now if i do :
$(question.options).each(function(k,v){
console.log(k,v)
// This should spit out: 1,a; 2,b; etc,etc ....
});
But its spits out options as a single object : 0 Object { 1=”1 – 20″, 2=”21 – 30″, more…}
You should use
$.each(object, fn)to iterate over a plain JS object. jQuery doesn’t officially support passing a plain object to its constructor.