Below I will share with you a JS method for transposing two-dimensional arrays horizontally and vertically. It has a good reference value and I hope it will be helpful to everyone. Let’s take a look together
I want to rotate a two-dimensional array horizontally and vertically. I don’t believe I am the only one who has this need, but I have searched on Baidu for a long time and searched all over the world...
Later it turned out that Google is still easy to use as the master said~ The first one is, despise Baidu
This record is recorded for the convenience of all Taoist friends (I really want to say "Fellow Immortal" ", the sequelae of being poisoned by a drama recently~~~)
##
var newArray = arr[0].map(function(col, i) { return arr.map(function(row) { return row[i]; }) });
How to get data in javascript from WeChat applet
About passing array parameters from js to the background controller Methods
The above is the detailed content of How to transpose a two-dimensional array horizontally and vertically in JS. For more information, please follow other related articles on the PHP Chinese website!