<script>
let data1 = [
{ name: "Tom", age: "18" },
{ name: "sun", age: "28" },
];
let data2 = [{ gender: "male" }, { gender: "female" }];
let result = data1.map((x, i) => ({
...x,
...data2[i],
}));
console.log(result);
</script>
结果: