How to create a unique array of json objects with sort on a field?
问题 How can I filler the below array on common id and output should have unique and latest history number const input = [{ "id": 134116, "user": "admin", "historyno": "134116-0" }, { "id": 134132, "user": "admin", "historyno": "134132-0" }, { "id": 134132, "user": "admin", "historyno": "134132-1" }, { "id": 134133, "user": "admin", "historyno": "134133-0" }, { "id": 134133, "user": "admin", "historyno": "134133-1" }]; let output = []; let tempId; for (let i = 0; i < input.length; i++) { if (input