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

Return to Revisions

2 of 2
Second, backward compatible solution
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] ]
 }
}
Akxe
  • 11.8k
  • 6
  • 43
  • 80

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