LoginSignup
33

More than 5 years have passed since last update.

2次元配列を1次元配列にする。

Posted at

Array.prototype.concat.applyを使う。

var ary = [[1,2,3,4,5,6,7],[8,9,10],[11,12]];
var ary2 = Array.prototype.concat.apply([],ary);
/*
ary2 == [1,2,3,4,5,6,7,8,9,10,11,12];
*/

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33