How to convert [object Object],[object Object] to [Object, Object] in javascript? -


was trying send static data websocket , receive same. data is

var details=     [       {         "_id": "5799fac61ee480492224071a",         "index": 0,         "age": 25,         "name": "jean pierce",         "gender": "female",         "email": "jeanpierce@cincyr.com"       },       {         "_id": "5799fac678aae9a71af63ef2",         "index": 1,         "age": 23,         "name": "laurie lopez",         "gender": "female",         "email": "laurielopez@cincyr.com"       },       {         "_id": "5799fac6c237d929693c08d7",         "index": 2,         "age": 21,         "name": "padilla barrett",         "gender": "male",         "email": "padillabarrett@cincyr.com"       }     ]; 

when above data received, in form of string, parsed json using json.parse(data) , store in local variable. now, issue here is, parsing, need converted [object,object] form instead of [object object],[object object] coming on console. how achieve ?

update: code same below, please have check.

sending data websocket server using below code

 if (client.readystate === client.open) {                                    client.send(json.stringify(details));                                    } 

on receiving end data received -

client.onmessage = function(e) {          console.log(" fetched data :"+json.parse(e.data));           this.setstate({   val:   json.parse(e.data)                     });             }.bind(this); 

the console.log() in second statement showing result [object object],[object object] parsing same in react [ object object] needed. how achieve ?

console image

here go:

console.log('[' + array.fill('object').tostring() + ']') 

test:

var array = [    {      "_id": "5799fac61ee480492224071a",      "index": 0,      "age": 25,      "name": "jean pierce",      "gender": "female",      "email": "jeanpierce@cincyr.com"    },    {      "_id": "5799fac678aae9a71af63ef2",      "index": 1,      "age": 23,      "name": "laurie lopez",      "gender": "female",      "email": "laurielopez@cincyr.com"    },    {      "_id": "5799fac6c237d929693c08d7",      "index": 2,      "age": 21,      "name": "padilla barrett",      "gender": "male",      "email": "padillabarrett@cincyr.com"    }  ]    console.log('[' + array.fill('object').tostring() + ']')

though don't know why you'd want on other - both equally (un)helpful. sure don't want console.dir?


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -