0

I want this

 [{ prop1: '100', prop2: false, prop3: null, prop4: 'abc' },
  { prop1: '102', prop2: false, prop3: null, prop4: 'def' } 
   ]

to be converted to this

[[100,false,null,'abc'] , [102,false,null,'def']]

in Node.js

0

2 Answers 2

0

You can map the array by taking Object values of the object.

const array =  [{ prop1: '100', prop2: false, prop3: null, prop4: 'abc' }, { prop1: '102', prop2: false, prop3: null, prop4: 'def' }];

const result = array.map(item=>Object.values(item));

console.log(result);

Sign up to request clarification or add additional context in comments.

Comments

0

Use reduce func to generate a new array result.

const data = [
  { prop1: '100', prop2: false, prop3: null, prop4: 'abc' },
  { prop1: '102', prop2: false, prop3: null, prop4: 'def' }
];

let result = data.reduce((acc: any, item: any) => {
  acc.push(Object.values(item));

  return acc;
}, []);

console.log(result);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.