JavaScript How to list the values of a json object that are equal to key in an array? values_list json,django values_list json,python list json values,array

const columns = ['dataA', 'dataD', 'dataB', 'dataE'];

const data = [{
    dataA: '001a',
    dataB: '123456',
    dataC: 'true',
    dataD: 'normal',
    dataE: 'ON'
  },
  {
    dataA: '002a',
    dataB: '123456',
    dataC: 'true',
    dataD: 'exception',
    dataE: 'ON'
  },
  {
    dataA: '003a',
    dataB: '098767',
    dataC: 'true',
    dataD: 'normal',
    dataE: 'OFF'
  },
  {
    dataA: '001a',
    dataB: '567890',
    dataC: 'false',
    dataD: 'normal',
    dataE: 'ON'
  }
];

const result = data.map(a => columns.map(k => {
  return {
    [k]: a[k]
  };
}));

console.log(result);
Answer:1

You are on the right path. Note that object properties are inherently unordered, don't rely on them being in a particular order.

const columns = ['dataA', 'dataD', 'dataB', 'dataE'];

const data = [{ dataA: '001a', dataB: '123456', dataC: 'true', dataD: 'normal', dataE: 'ON' }, { dataA: '002a', dataB: '123456', dataC: 'true', dataD: 'exception', dataE: 'ON' }, { dataA: '003a', dataB: '098767', dataC: 'true', dataD: 'normal', dataE: 'OFF' }, { dataA: '001a', dataB: '567890', dataC: 'false', dataD: 'normal', dataE: 'ON' }];

const result = data.map(a => columns.reduce((acc, curr) => ({
  ...acc, [curr]: a[curr]
}), {}))

console.log(result);

/*
[
  {
    "dataA": "001a",
    "dataD": "normal",
    "dataB": "123456",
    "dataE": "ON"
  },
  {
    "dataA": "002a",
    "dataD": "exception",
    "dataB": "123456",
    "dataE": "ON"
  },
  {
    "dataA": "003a",
    "dataD": "normal",
    "dataB": "098767",
    "dataE": "OFF"
  },
  {
    "dataA": "001a",
    "dataD": "normal",
    "dataB": "567890",
    "dataE": "ON"
  }
]
*/
Answer:2

I'm struggling with the issue of onclick function and replacing html in DOM. The function is responsible for: 1. reading the whole list from the DOM, 2. changing its order accordingly to ID I get ...

I'm struggling with the issue of onclick function and replacing html in DOM. The function is responsible for: 1. reading the whole list from the DOM, 2. changing its order accordingly to ID I get ...

  1. function of beauty
  2. function notation
  3. function definition
  4. function calculator
  5. function of mitochondria
  6. function of nucleus
  7. function of carbohydrates
  8. function of cell membrane
  9. function of proteins
  10. function of beauty reviews
  11. function of lipids
  12. function of cytoplasm
  13. function synonym
  14. function of nucleic acids
  15. function of dna
  16. function of liver
  17. function math definition
  18. function of vacuole
  19. function of pancreas
  20. function of cerebellum

I am trying to display a popover on click over a react-select selected value element as follow : My issue happens when I click on the popover trigger, the dropdown opens and the popover too... I ...

I am trying to display a popover on click over a react-select selected value element as follow : My issue happens when I click on the popover trigger, the dropdown opens and the popover too... I ...

  1. react select cannot select value
  2. react-select cannot read property 'value' of null
  3. react-select cannot read property 'reduce' of null
  4. react-select cannot read property 'tolowercase' of undefined
  5. react-select cannot read property 'scrollheight' of undefined
  6. react-select-plus cannot read property 'string' of undefined
  7. react-select function components cannot be given refs
  8. react-select cannot read property 'func' of undefined

I know we all use promises to avoid function callback hell, but my question is where in the event loop the promise code runs and whether the code is really asynchronous. I mean, is this code ...

I know we all use promises to avoid function callback hell, but my question is where in the event loop the promise code runs and whether the code is really asynchronous. I mean, is this code ...

I'm trying to use shallow from enzyme and also use snapshots from jest together. The problem I'm facing is that I need to change something from the state using setState() from enzyme and then match ...

I'm trying to use shallow from enzyme and also use snapshots from jest together. The problem I'm facing is that I need to change something from the state using setState() from enzyme and then match ...

  1. enzyme shallow with context
  2. enzyme shallow with props
  3. enzyme shallow with hooks
  4. enzyme shallow with provider
  5. enzyme shallow with state
  6. enzyme shallow with intl
  7. enzyme shallow with store
  8. enzyme shallow with redux
  9. enzyme shallow with theme
  10. enzyme shallow with hoc
  11. enzyme shallow with ref
  12. enzyme shallow to json
  13. enzyme shallow and mount
  14. enzyme shallow to html
  15. enzyme shallow to string
  16. enzyme shallow render with provider
  17. enzyme shallow render with props
  18. enzyme find with shallow