我有一个很好的谜题,我希望能解决。可能有更好的方法可以做到这一点,我对想法持开放态度。我正在尝试为画布绘图应用程序编写撤消功能。我有以下对象,其中包含一个数组,其中包含具有三个属性的自己的对象。
var allDamages= {};
allDamages['scratch'] = [];
allDamages['scratch'].push({"x":4,"y":6,"index":1});
allDamages['scratch'].push({"x":3,"y":3,"index":2});
allDamages['scratch'].push({"x":9,"y":9,"index":3});
allDamages['scratch'].push({"x":19,"y":39,"index":4});
allDamages['dent'] = [];
allDamages['dent'].push({"x":59,"y":69,"index":5});
allDamages['dent'].push({"x":59,"y":69,"index":9});
allDamages['dent'].push({"x":39,"y":19,"index":6});
allDamages['rip'] = [];
allDamages['rip'].push({"x":20,"y":22,"index":7});
allDamages['rip'].push({"x":100,"y":56,"index":8});
我想从这个数组中删除最后一个条目。我想通过属性“索引”来做到这一点。所以我需要以某种方式找到属性“索引”具有最高值的条目,然后将其从数组中删除。这样做的最佳方法是什么?
问候,
罗伯特