Q:

Get the highest attribute value from a set of DOM elements

I have a set of DOM elements with data attributes. How can I get the maximum value?
<li data-for-something="1"></li>
<li data-for-something="1"></li>
<li data-for-something="2"></li>
<li data-for-something="3"></li>
<li data-for-something="4"></li>

I can use $('[data-some-value]') to get all the li with this attribute, and then loop through them. But I'm not sure what js or jquery methods are available to make this easier. 
The best I've got is doing this:
function getMaxAttributeValue(attribute_name) {
  var max_value = 0;
  $('[' + attribute_name + ']').map(function(){
    var this_value = this.attr(attribute_name);
    if (this_value > max_value) {
      max_value = this_value;
    }
  });
  return max_value;
}

A:

I like this way:
function getMaxAttributeValue(attribute_name) {
  return Math.max.apply( Math, $('[' + attribute_name + ']').map(function(){
    return Number($(this).attr(attribute_name)) || -Infinity;
  }))
}

console.log(getMaxAttributeValue("data-for-something"))  // outputs 4

