There is such a task - to track the last message in the chat. I decided to track it in time, I collect an array, it only remains to pull out the very maximum value, since I'm still a beginner, I get confused in some things. This script displays -Infinity, and Google brings, although the question is, I understand that it is simple.
var timestamp = {}; $('a.times').each(function(i, el){ var val = $(el).attr('data-temp'); var name = $(el).attr('data-cgid'); timestamp[name] = Number(val); }); var maxTime = Math.max.apply(timestamp); console.log(maxTime);