javascript - JS Combine array values into one single value -


i have object

a = {key:'animals',      options: ['dog','cat','penguin']} 

how can simplify this:

b = ['animals','dogcatpenguin'] 

like

var = {    key: 'animals',    options: ['dog','cat','penguin']  };    var key, b = [];    (key in a) {    b.push(array.isarray(a[key]) ? a[key].join('') : a[key]);  }    console.log(b);

or can use object.keys .map

var = {      key: 'animals',      options: ['dog','cat','penguin']  };    var b = object.keys(a).map(function (key) {      return array.isarray(a[key]) ? a[key].join('') : a[key];       });    console.log(b);


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -