Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Second, backward compatible solution
Source Link
Akxe
  • 11.8k
  • 6
  • 43
  • 80

You can simply map old array to the new one.

var newArray = arr.map( second => second.map( third => [ third ] ))

Or more backwards compatible version

var newArray = []
for(var i = array.length - 1; i >= 0; i—-){
 var second = array[i];
 newArray[i] = []
 for(var j = second.length - 1; j >= 0; j—-){
 newArray[i][j] = [ second[j] ]
 }
}

You can simply map old array to the new one.

var newArray = arr.map( second => second.map( third => [ third ] ))

You can simply map old array to the new one.

var newArray = arr.map( second => second.map( third => [ third ] ))

Or more backwards compatible version

var newArray = []
for(var i = array.length - 1; i >= 0; i—-){
 var second = array[i];
 newArray[i] = []
 for(var j = second.length - 1; j >= 0; j—-){
 newArray[i][j] = [ second[j] ]
 }
}
Source Link
Akxe
  • 11.8k
  • 6
  • 43
  • 80

You can simply map old array to the new one.

var newArray = arr.map( second => second.map( third => [ third ] ))
lang-js

AltStyle によって変換されたページ (->オリジナル) /