I got a json object in javascript like var json = {\"20121207\":\"13\", \"20121211\":\"9\", \"20121213\":\"7\", \"20121219\":\"4\"}; without knowing the
var json = {\"20121207\":\"13\", \"20121211\":\"9\", \"20121213\":\"7\", \"20121219\":\"4\"};
If you don't need to support old JS engines:
var lastKey = Object.keys(json).sort().reverse()[0]; var lastValue = json[lastKey];
Don't assume the keys are in order. Get the keys, and then sort them, and then grab that largest value after the sort.