I am trying to take the last element in a JSON
. I know order is not preserved, but the keys are unix
timestamps so I can just sort. I am working from this question:
get last element of a json object in javascript
But I get nothing logged to the console and no errors.
my code:
var mydata = {"1509937402379":"7348.01","1509937412486":"7348.01","1509937422253":"7348.01","1509937426286":"7348.01","1509937430066":"7345.54"}
console.log(mydata[Object.keys(obj).sort().pop()]);