【发布时间】:2020-10-20 12:17:54
【问题描述】:
如何使用 javascript 拆分以下数组? 我在这里要做的是将这个数组拆分为这个数组内的多个数组,这些数组应该是唯一的 1、2、3、4、5 个候选配置 ID
0: {candidateConfigId: "1", value: "199128700790"}
1: {candidateConfigId: "2", value: "Yujith"}
2: {candidateConfigId: "3", value: "Male"}
3: {candidateConfigId: "4", value: "SE"}
4: {candidateConfigId: "5", value: "Colombo5"}
5: {candidateConfigId: "1", value: "199128700792"}
6: {candidateConfigId: "2", value: "Yujith2"}
7: {candidateConfigId: "3", value: "Male"}
8: {candidateConfigId: "4", value: "SE"}
9: {candidateConfigId: "5", value: "Colombo3"}
10: {candidateConfigId: "1", value: "199128700793"}
11: {candidateConfigId: "2", value: "Yujith3"}
12: {candidateConfigId: "3", value: "Male"}
13: {candidateConfigId: "4", value: "SE"}
14: {candidateConfigId: "5", value: "Colombo2"}
预期输出
[
[
0: {candidateConfigId: "1", value: "199128700790"}
1: {candidateConfigId: "2", value: "Yujith"}
2: {candidateConfigId: "3", value: "Male"}
3: {candidateConfigId: "4", value: "SE"}
4: {candidateConfigId: "5", value: "Colombo5"}
],
[
0: {candidateConfigId: "1", value: "199128700792"}
1: {candidateConfigId: "2", value: "Yujith2"}
2: {candidateConfigId: "3", value: "Male"}
3: {candidateConfigId: "4", value: "SE"}
4: {candidateConfigId: "5", value: "Colombo3"}
],
[
10: {candidateConfigId: "1", value: "199128700793"}
11: {candidateConfigId: "2", value: "Yujith3"}
12: {candidateConfigId: "3", value: "Male"}
13: {candidateConfigId: "4", value: "SE"}
14: {candidateConfigId: "5", value: "Colombo2"}
]
]
Thanks in advance
【问题讨论】:
-
数组是否按上述排序?你试过什么?
标签: javascript node.js arrays reactjs split