我有4个数组,如下所示
array1 = ["one", "two", "three"];
array2 = ["1", "2", "3"];
array3 = ["a", "b", "c"];
array4 = ["10", "20", "30"];
通过使用这些数组的元素,我需要创建如下的另一组数组
oneArray = ["one", "1", "a", "10"];
twoArray = ["two", "2", "b", "20"];
threeArray = ["three", "3", "c", "30"];
有没有简单的方法可以做到这一点?
答案 0 :(得分:1)
使用lodash:
array1 = ["one", "two", "three"];
array2 = ["1", "2", "3"];
array3 = ["a", "b", "c"];
array4 = ["10", "20", "30"];
result = _.zip(array1, array2, array3, array
这应该给您:
[
["one", "1", "a", "10"],
["two", "2", "b", "20"],
["three", "3", "c", "30"]
]
答案 1 :(得分:1)
是的,这很简单
const array1 = ["one", "two", "three"];
const array2 = ["1", "2", "3"];
const array3 = ["a", "b", "c"];
const array4 = ["10", "20", "30"];
const oneArray = [array1[0],array2[0],array3[0],array4[0]];
const twoArray = [array1[1],array2[1],array3[1],array4[1]];
const threeArray = [array1[2],array2[2],array3[2],array4[2]];
console.log([oneArray, twoArray, threeArray])
答案 2 :(得分:0)
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.1: La valeur '2.2' de l'attribut 'version' de l'?l?ment 'persistence' n'est pas valide au regard de l'utilisation de l'attribut correspondant. L'attribut 'version' doit avoir la valeur fixe de '2.1.
答案 3 :(得分:0)
在一个数组中组合数组,并使用map
。即使您的数组大小从3个元素增加到更多,这也应该起作用。
const array1 = ["one", "two", "three"];
const array2 = ["1", "2", "3"];
const array3 = ["a", "b", "c"];
const array4 = ["10", "20", "30"];
const all = [array1, array2, array3, array4];
const [oneArray, twoArray, threeArray] = all[0].map((_, i) => all.map(arr => arr[i]));
console.log(oneArray);
console.log(twoArray);
console.log(threeArray);
答案 4 :(得分:0)
尝试此代码。它会解决您的问题。
<security:http auto-config="false" use-expressions="true" entry-point-ref="authEntryPoint" disable-url-rewriting="true">
<security:intercept-url pattern="/" access="isAnonymous() or isAuthenticated()" />
<security:intercept-url pattern="/index.jsp" access="isAnonymous() or isAuthenticated()" />
<security:intercept-url pattern="/another-url" access="isAnonymous() or isAuthenticated()" />
...
<security:intercept-url pattern="/**" access="isAuthenticated()" />
</security:http>