[英]javascript convert elements of an array into array for themselves
How can I convert the elements of the array into another array? 如何将数组的元素转换为另一个数组?
let a = [2, 4, 0, 8, 9, 15]
and the result will be : 结果将是:
a = [[2], [4], [0], [8], [9], [15]]
let a = [2, 4, 0, 8, 9, 15];
let b = a.map((item) => [item]);
a = [2, 4, 0, 8, 9, 15]
console.log(result = a.map((n) => [n]))
b=[]
//you can try below also
for (i in a){
b.push([i]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.