我有两个具有相同维度的数组,一个用于频率,一个用于值。
示例:
var value = [20, 40, 10, 80, 16];
var frequency = [10, 16, 25, 31.5, 40];
我以这种方式使用了 math.max 方法
var maxValue = Math.max.apply(Math, value);
现在我想找到频率数组中相同位置的频率。
最佳答案
假设值是唯一的。
var maxValue = Math.max.apply(Math, value);
var index = value.indexOf(maxValue);
var freq = frequency[index];
关于javascript - 在数组中查找最大值及其在 javascript 中的对应项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43225181/