var arr = ["subId":"dfsfsdfsdfSUB201800099","userID":"dfsfsdfsdf"}, {""subId":"dfsfsdfsdfSUB201800139","userID":"dfsfsdfsdf"}, {""subId":"dfsfsdfsdfSUB201700649","userID":"dfsfsdfsdf"} , {}, {}............]
我有一个数组,我想找到subId的值,该值包含“ dfsfsdfsdfSUB2017”,在此示例中为最大值00139。
答案 0 :(得分:0)
这可能会帮助您:
let someArray = [{
"subId": "dfsfsdfsdfSUB201800099",
"userID": "dfsfsdfsdf"
}, {
"subId": "dfsfsdfsdfSUB201800139",
"userID": "dfsfsdfsdf"
}, {
"subId": "dfsfsdfsdfSUB201700649",
"userID": "dfsfsdfsdf"
}]
let ids = someArray.map(item => parseInt(item.subId.split('dfsfsdfsdfSUB')[1]))
console.log(Math.max(...ids))