LoginSignup
56
44

More than 5 years have passed since last update.

配列の中にオブジェクトが入っている場合のvalue値の取得方法二次元配列 Javascript

Last updated at Posted at 2019-02-05

備忘録として残しておきます。
以下のような配列で、key値のvalue値を取得した時に使うmap関数について、今日教わったのでメモメモ。

  const ArrayTest = [{
            id: 1,
            name: "callen"
        }, {
            id: 2,
            name: "Tom"
        }, {
            id: 3,
            name: "John"
        }];
        const list = ArrayTest.map(obj => obj.name);
        console.log(list);

結果
スクリーンショット 2019-02-05 22.20.30.png

APIでJSONを扱う時に使える。
超絶便利。

参考資料

配列内のオブジェクトをフォーマットするために map を使用する MDN web docs

56
44
1

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
56
44