【发布时间】:2019-11-28 05:29:03
【问题描述】:
[
{
"clauseId": 1,
"clauseName": "cover",
"texts": [
{
"textId": 1,
"text": "hello"
}
]
},
{
"clauseId": 3,
"clauseName": "xyz",
"texts": [
{
"textId": 3,
"text": "hello Everyone"
},
{
"textId": 4,
"text": "Some data"
}
]
}
{
"clauseId": 2,
"clauseName": "joining",
"texts": [
{
"textId": 3,
"text": "hello1"
},
{
"textId": 4,
"text": "hello2"
}
]
}
]
如果我列一个像
这样的列表a=[joining,cover]
我想要一个新的列表形成为
b=[hello1,hello2,hello]
请注意,每个元素的索引都很重要如果我反转索引
b =[hello,hello1,hello2]
如果
a=[xyz,joining,cover]
b=["hello Everyone","Some data",hello1,hello2,hello]
类似如果我在 [joining,xyz,cover] 中交换位置
b=["hello1","hello2","hello Everyone","Some data",hello]
请注意,传入的数据可以有多个clauseName和多个文本。这只是一个演示
【问题讨论】:
标签: javascript arrays angular typescript list