简体   繁体   中英

push data index into an array in extjs

let's say if the console.log(response) is

{
    responseText : {
      "success":true,
      "code":0,
      "error":null,
      "total":1,
      "data":[
        {
          "DATE":"2018-02-07",
          "1.1":"10","1.2":"3"
        },
        {
          "DATE":"2018-03-04",
          "1.1":"1",
          "1.2":"5"
        }
      ]
    }
};

How to push properties 1.1 , 1.2 into an array in extjs. Have to omit the date

What you're asking can be achieved using JavaScript ES6.

Like this

const obj = {
    responseText : {
      "success":true,
      "code":0,
      "error":null,
      "total":1,
      "data":[
        {
          "DATE":"2018-02-07",
          "1.1":"10","1.2":"3"
        },
        {
          "DATE":"2018-03-04",
          "1.1":"1",
          "1.2":"5"
        }
      ]
    }
};

const data = obj.responseText.data;

let myArr = [];
data.map((date) => 
  myArr = [...Object.keys(date).filter(key => key != 'DATE')]);

console.log(myArr)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM