如何从一组元素中删除元素,这些数组的元素与JavaScript中的字符串连接在一起?
我目前有此集合:
Set1 = {
Alpha: [One, Two],
Beta: [One, Two, Three],
Delta: [One]
}
我也有一系列元素:
Arr1 = [Alpha_One, Beta_One, Beta_Two, Delta_One]
我正在寻找一种方法,以编程方式删除此集合中各自的数组中发现的所有元素,如:
Set1 = {Alpha: [Two], Beta: [Three], Delta: []}
据我所知,<代码> foreach()方法不会使用语句,因此我不知道是否还有另一种方法可以做。
I currently have this set:
Set1 = {
Alpha: [One, Two],
Beta: [One, Two, Three],
Delta: [One]
}
I also have this array of elements:
Arr1 = [Alpha_One, Beta_One, Beta_Two, Delta_One]
I'm looking for a way to programmatically remove all of the elements that are found in this set to it's respective array, like so:
Set1 = {Alpha: [Two], Beta: [Three], Delta: []}
As far as I know, the forEach()
method does not take if statements, so I don't know if there is another method to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需找到索引和剪接即可。
Just find the index and splice.
将您的arr1和剪接elem与精确键分开
Split your Arr1 and splice elem from exact key