如何使用jquery在数组对象集合中查找最小价格?
我有一个var计算数组=[];它包含一些对象,每个对象都有与之相关联的价格。我需要在该集合中找到最小的价格,并需要从数组集合中删除该对象。我正在做以下事情,但没有成功我怎么能做到这一点如何使用jquery在数组对象集合中查找最小价格?,jquery,Jquery,我有一个var计算数组=[];它包含一些对象,每个对象都有与之相关联的价格。我需要在该集合中找到最小的价格,并需要从数组集合中删除该对象。我正在做以下事情,但没有成功我怎么能做到这一点 while (chargedItems > 0) { currCustomziationPrice = currCustomziationPrice + Math.min.apply(Math, calculation.price); // 1 chargedItems = chargedI
while (chargedItems > 0) {
currCustomziationPrice = currCustomziationPrice + Math.min.apply(Math, calculation.price); // 1
chargedItems = chargedItems - 1;
calculation.splice($.inArray(itemtoRemove, arr), 1);
alert(currCustomziationPrice + "___" + chargedItems);
}
但是计算数组有对象,每个对象都有属性价格。。我不知道你的代码在做什么。如果计算是一个数组,那么:
calculation.price
返回什么?应该是calculation[index]。price
$.each(arrayVariable, function() {
var lowest = Math.min.apply(null, grid);
var index = grid.indexOf(lowest);
grid[index] += $(this).height();
}