1

Here is the code

var obj = {!!json_encode($assets_name)!!}

Object.keys(obj).forEach(function(key) {

console.log(key, obj[key]);

});

//Actual Result

enter image description here

// Trying to Get

Is there a way to get this result?

Keyboard,Mouse,Spoons,Paper,Keyboard
Salim Djerbouh
  • 10,719
  • 6
  • 29
  • 61
Kiruaaa
  • 191
  • 1
  • 12
  • Looks like your `obj` is actually an array of objects. – Nick Parsons Nov 02 '19 at 12:07
  • 1
    Does this answer your question? [From an array of objects, extract value of a property as array](https://stackoverflow.com/questions/19590865/from-an-array-of-objects-extract-value-of-a-property-as-array) – Nick Parsons Nov 02 '19 at 12:13

1 Answers1

4

Instead of Object.keys use Object.values which will return a array of the value. Then you can use join(',') which will return a string joined by comma

brk
  • 48,835
  • 10
  • 56
  • 78