Home > Back-end >  JS remove array variable names
JS remove array variable names

Time:10-05

I'm new in JS... can someone help me to change this:

arr = [{type:'fruit', name:'apple', color:'red'},{type:'fruit', name:'banana', color:'yellow'}]

to this:

arr = [['fruit', 'apple', 'red'],['fruit', 'banana', 'yellow']]

CodePudding user response:

You can map your array using Object.values() as a callback:

arr = arr.map(Object.values):

CodePudding user response:

map your array using Object.values()

arr = arr.map(Object.values):

  • Related