在React Native JSX中,如何连接两个这样的字符串映射?

const map1 = { title: 'Avengers: Infinity War', genre: 'Action, Adventure, Fantasy' };
const map2 = { directors: 'Anthony Russo, Joe Russo', stars: ' Robert Downey Jr., Chris Hemsworth, Mark Ruffalo' };


我想要的结果:

{ title: 'Avengers: Infinity War', genre: 'Action, Adventure, Fantasy',  directors: 'Anthony Russo, Joe Russo', stars: ' Robert Downey Jr., Chris Hemsworth, Mark Ruffalo' }


谢谢你的帮助!

最佳答案

const map1 = { title: 'Avengers: Infinity War', genre: 'Action, Adventure, Fantasy' };
const map2 = { directors: 'Anthony Russo, Joe Russo', stars: ' Robert Downey Jr., Chris Hemsworth, Mark Ruffalo' };

console.log(Object.assign({}, map1, map2));





Object.assign({}, map1, map2);

关于javascript - 在JavaScript中合并两个字符串映射,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52471191/

10-14 04:24