javascript - Getting the value of a js object key -


i need able value of object key. when console.log(event); returned object, getting:

messageevent {     ports: array[0],      data: "{         "event":"playprogress",         "data":{             "seconds":0.419,             "percent":0.002,             "duration":177.813         }     }" } 

i can't seem value of data.percent console.log(event.data.percent). doing wrong?

it looks event.data string, , not nested object. "reasonably modern" browser, can:

var data = json.parse(event.data); console.log(data.percent); 

more discussion on json.parse can seen @ previous stackoverflow answer.


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -