let arr = [ { id: 1, name: "hong" }, { id: 2, name: "huang" }, { id: 3, name: "lan" } ] let obj = { id: 2, name: "gyang"} arr = arr.map(item => item.id === obj.id ? obj : item) console.log(arr)