我有两个数组:
let users = ["user1", "user2", "user3"];
let onlineUsers = [{name: "user1", id: 123}, {name: "user2, id: 345}];
如何从这些阵列中获得一个阵列。如果来自onlineUsers的用户存在于用户数组中以添加id,如果不存在,则id为null。像这样:
let result = [{name:"user1", id: 123}, {name:"user2", id: 345}, {name: "user3", id: null}]