From the following object, how can I get the 'air' reading from the property with largest index key i.e. 4? (30.9)
{
1: {
air: "31.2",
evap: "25.3",
t_condenser: "43.8"
},
2: {
air: "31.1",
evap: "25.3",
t_condenser: "43.6"
},
3: {
air: "31.0",
evap: "25.3",
t_condenser: "43.5"
},
4: {
air: "30.9",
evap: "25.2",
t_condenser: "43.3"
}
}
I have tried the following, to try to get the last key, but it just reads undefined:
$.getJSON("handler.php?action=fetchLAE", function(data){
console.log(data.length);
});