javascript - I want to access the values of the keys of an object? -
i'm using api , i'm getting response of on success function data.
i'm trying use gives me "keys" of objects not there values, question is: can values using below approach?
i have got "keys" of objects using javascript's object.key()
method want values too.
here response. have taken snippet of response here got in console.
division: object active: 1 country: "united states" lat: 42.3584647 lon: -71.05962 name: "boston" url: "http://yipit.com/boston/"
below function written key of object:
function getvalues(data){ for(var = 0;i <= data.response.deals.length-1; i++){ var obj = []; var num = + 1; var keyarray = object.keys(data.response.deals[i].division); $('#empid h6').html(keyarray); //here keys of objects country,lat,lon etc. console.log("value of keyarray "+num+" "+keyarray); } }
the underscore library has sort of nice helpers going functional, #values() helper:
> myobj= { division: 'division', name: 'boston', url: 'http://yipit.com/boston/' } > _.values(myobj); [ 'division', 'boston', 'http://yipit.com/boston/' ]
Comments
Post a Comment