Javascript Array Object Property Undefined -
when attempt access array object (preivous_data
) console outputs this:
[object { label="line1", data=[13]}]
as expected. however, when access array object property (preivous_data.data
) console gives undefined
. confused - error making not display array values property data
in object?
as further test, converted object json.stringify
, javascript object. again found same issues accessing property value of object:
function dataupdate(passed_ondatareceived_data){ console.log("passed object") // console output: passed object preivous_data = passed_ondatareceived_data console.log(preivous_data) // console output: [object { label="line1", data=[13]}] console.log(preivous_data.data) // console output: undefined var json_stringify = json.stringify(preivous_data); console.log(json_stringify) // console output:[{"label":"line1","data":[[0,88],[1,28],[2,52],[3,7],[4,93],[5,78],[6,53],[7,64],[8,43],[9,77],[10,58],[11,74],[12,5]]}] var myobject = eval('(' + json_stringify + ')') console.log(myobject) // console output: [object { label="line1", data=[13]}] console.log(myobject.data) // console output: undefined }
any appreciated.
looks have object previous_data
array.
[object { label="line1", data=[13]}]
so need previous_data[0].data
access data attribute.
Comments
Post a Comment