Simplest way to merge ES6 Maps/Sets?(合并 ES6 地图/集的最简单方法?)
问题描述
有没有一种简单的方法可以将 ES6 Maps 合并在一起(比如 Object.assign
)?既然我们在这里,那么 ES6 集合(如 Array.concat
)呢?
Is there a simple way to merge ES6 Maps together (like Object.assign
)? And while we're at it, what about ES6 Sets (like Array.concat
)?
推荐答案
对于套装:
对于地图:
请注意,如果多个映射具有相同的键,则合并映射的值将是具有该键的最后一个合并映射的值.
Note that if multiple maps have the same key, the value of the merged map will be the value of the last merging map with that key.
这篇关于合并 ES6 地图/集的最简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!