我在JS两个对象对象连接在一起地图在JS(ES6)
positions: {
top: { top: 10, left: 10 },
bottom: { top: 10, left: 10 },
left: { top: 10, left: 10 },
right: { top: 10, left: 10 },
},
positionAdjustments: {
top: { top: 0, left: 0 },
bottom: { top: 5, left: 5 },
left: { top: 0, left: 0 },
right: { top: 0, left: 0 },
},
我想将它们结合起来,以产生,例如: -
positions: {
top: { top: 10, left: 10 },
bottom: { top: 15, left: 15 },
left: { top: 10, left: 10 },
right: { top: 10, left: 10 },
},
是否有lodash方法或一些优雅的方式来实现这一点,而不写一些递归映射函数?例如:如果
positions.deepCombineValues(positionAdjustments);
为什么最后'left'是'0'? – ozil
可能是一个错字 – beniutek
@ ozil sry是一个错字! –