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
  • 9,886
  • 5
  • 23
  • 55
Kiruaaa
  • 157
  • 1
  • 10
  • 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

3

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
  • 46,805
  • 5
  • 49
  • 71