LoginSignup
1
0

More than 5 years have passed since last update.

配列メソッドを使ったTips

Posted at
var arr = [[0, 1, 2, 3], [4, 5, 6, 7]];

//2次元配列の最初の値だけ返す
var firstItems = arr.map(function (x) { return x[0]; });

//有効な要素だけをフィルタリング(excludes null, undefined, 0, etc…)
var enableItems = firstItems.filter(function (x) { return x; });
1
0
0

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
1
0