How to extract data by key from an array?

  • 0
    There is an array in which data is stored in the following form:
    [{"i":111111,"a":"00000000","st":0},{"i":222222,"a":"00000000","st":0},{"i":333333,"a":"00000000","st":0}]

    How to select data from an array into a new variable so that only the values ​​with the "i" key remain.
    For example in this form:
    [111111,222222,333333]
    Or like this:
    [{"i": 111111}, {"i": 222222}, {"i": 333333}]
    JavaScript Ronan Calderon, Jan 4, 2019

  • 1 Answers
  • 0
    arr.map (({i}) = & gt; i);



    arr.map (({i}) = & gt; ({i}));
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!