我有数组,其中有sequence number. 我只想从基于数组的数组中选择前 3 个,sequence numbers而不是像 "sequesnce": "9.80.709.5This is my array这样的序列号
array1=[
{
"orgId": 101,
"dId": 494,
"name": "Test1",
"sequesnce": "6.408.06.0 Sequesnce Date : Mon 08/06/2019 (Sections: P4.00344) Italy CR"
},
{
"orgId": 102,
"dId": 442,
"name": "Test2",
"sequesnce": "9.80.709.5 Sequesnce Date : Mon 06/04/2019 (Sections: P4.00344) Italy CR",
},
{
"orgId": 103,
"sequesnce": "9.138.309.0 Sequesnce Date : Mon 06/03/2019 (Sections: P4.45600) Spain HR",
"dId": 494,
"name": "Test3",
},
{
"orgId": 103,
"sequesnce": "8.208.409.0 Sequesnce Date : Mon 10/03/2019 (Sections: P4.568787) Spain HR",
"dId": 494,
"name": "Test3",
},
{
"orgId": 103,
"sequesnce": "9.408.90.3 Sequesnce Date : Mon 08/06/2019 (Sections: P4.00344) Italy CR",
"dId": 494,
"name": "Test3",
},
我正在寻找输出
topThree=
{
"sequesnce": "9.80.709.5 Sequesnce Date : Mon 06/04/2019 (Sections: P4.00344) Italy CR",
},
{
"sequesnce": "9.408.90.3 Sequesnce Date : Mon 08/06/2019 (Sections: P4.00344) Italy CR",
},
{
"sequesnce": "9.138.309.0 Sequesnce Date : Mon 06/03/2019 (Sections: P4.45600) Spain HR",
},
我试过这个
function arrayMax(arr) {
return arr.reduce(function (p, v) {
return ( p > v ? p : v );
});
}]
var maximo = arrayMax(obj); //return the high
这让我回来
{
"orgId": 102,
"dId": 442,
"name": "Test2",
"sequesnce": "9.80.709.5 Sequesnce Date : Mon 06/04/2019 (Sections: P4.00344) Italy CR",
},
此代码返回单个数组而不是三个,并且不确定在所有情况下此逻辑是否有效。
BIG阳
慕慕森
肥皂起泡泡
相关分类