You are over-complicating things; you just need to map each entry in reports
to its reportId
property and convert that to an integer
let reports = [
{reportId: "21", title: "Online", code: "ON" },
{reportId: "11", title: "Retail", code: "RE" },
{reportId: "61", title: "Walk-in", code: "WI" }
]
let ids = reports.map(function (item) {
return parseInt(item.reportId, 10);
});
console.log(ids)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…