假设我们有一个数组:
var antibiotics = [{
bacteria: "Mycobacterium tuberculosis",
penicillin: 800,
streptomycin: 5,
neomycin: 2,
gram: "negative"
}, {
bacteria: "Salmonella schottmuelleri",
penicillin: 10,
streptomycin: 0.8,
neomycin: 0.09,
gram: "negative"
}, {
bacteria: "Proteus vulgaris",
penicillin: 3,
streptomycin: 0.1,
neomycin: 0.1,
gram: "negative"
}, {
bacteria: "Klebsiella pneumoniae",
penicillin: 850,
gram: "negative"
}];
并且我们希望在数组 (和此处) 中查找对象min
的所有数值属性,假设值可以为空/不存在。max
penicillin
streptomycin
neomycin
如何从 JavaScript 中的对象数组中聚合此类数据?