-1

I need to know that how could i extract data if i have response like this

Object {cast: Object}
    cast: Array[5]
        0: Object
            text: "Select Any"
            value: "000"
            __proto__: Object
        1: Object
        2: Object
        3: Object
        4: Object

Same this pattern in remaining Object

Update 1

I have array like this

var response = {};
response = showData();

and when i console.log(response) then in my console the above mention output will display and when i tried response.length it shows me undefined

Update 2

function showData(){
    var foodSubCatagories1 = {};
    foodSubCatagories1.cast = _context.FoodGroup.forEach(function(FG)
    {
        $('#selectCatagoryFood').append('<option value="'+FG.FoodGroupID+'">'+FG.Description+'</option>');
}).then(function(){
    $('#selectCatagoryFood').selectmenu('refresh');
foodSubCatagories1.cast = [
{
    value: "000",
    text: "Select Any"
},
{
    value: "1",
    text: "Juice"
},
{
    value: "2",
    text: "Dairy"
},
{
    value: "3",
    text: "Farm"
},
{
    value: "4",
    text: "Custom"
}
];
return foodSubCatagories1.cast;
});
return foodSubCatagories1;

}

Blu
  • 4,036
  • 6
  • 38
  • 65

1 Answers1

0
    for ( var c in response.cast ) 
    {
    console.log ( c ); // array item 
  console.log ( c.text); //  item propery 
    }
sino
  • 754
  • 1
  • 7
  • 22
  • 1
    Note: Using `for..in` with an `Array` [isn't typically recommended](http://stackoverflow.com/questions/500504/why-is-using-for-in-with-array-iteration-such-a-bad-idea). And, `c` will be a key, not a value. – Jonathan Lonowski Oct 03 '13 at 20:11