let data1 = [{"name": '小米'}, {"name": '小红'}, {"name": '小花'}, {"name": '小明'}]; let data2 = [ {"school": "清北", "type": "本科"}, {"school": "浙大", "type": "研究生"}, {"school": "复旦", "type": "大专"}, {"school": "剑桥", "type": "硕士"} ]; let result = data2.map(z=>data1.map(x=>({...x, ...z}))).flat() console.log('输出结果:',result); [ { "name": "小米", "school": "清北", "type": "本科" }, { "name": "小红", "school": "清北", "type": "本科" }, { "name": "小花", "school": "清北", "type": "本科" }, { "name": "小明", "school": "清北", "type": "本科" }, { "name": "小米", "school": "浙大", "type": "研究生" }, { "name": "小红", "school": "浙大", "type": "研究生" }, { "name": "小花", "school": "浙大", "type": "研究生" }, { "name": "小明", "school": "浙大", "type": "研究生" }, { "name": "小米", "school": "复旦", "type": "大专" }, { "name": "小红", "school": "复旦", "type": "大专" }, { "name": "小花", "school": "复旦", "type": "大专" }, { "name": "小明", "school": "复旦", "type": "大专" }, { "name": "小米", "school": "剑桥", "type": "硕士" }, { "name": "小红", "school": "剑桥", "type": "硕士" }, { "name": "小花", "school": "剑桥", "type": "硕士" }, { "name": "小明", "school": "剑桥", "type": "硕士" } ]
上面是“js用最简单的方法实现2个数组的交叉一对一合并”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_16205.html
workflows工作流
- 一朵染血的白玫瑰ComfyUI工作流
- 森林里一只邪恶的树妖ComfyUI工作流
- 骨骼般的恶魔修女ComfyUI工作流
- 一个神秘的隐藏面孔下一本书的剪影ComfyUI工作流
- 金属埃及人ComfyUI工作流
- 一只白色的孔雀ComfyUI工作流
- 3D几何打印人体模型ComfyUI工作流
- 蝴蝶兰comfyui工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!