I have a javascript method. I am trying to get id from data parameter.
data(spark, data){ console.log('receive ', data) console.log(data.id) }
first output line receive {id:1}
but the second output line is undefined
then I tried the method below to convert a json string to an object:
data(spark, data){ console.log('receive ', data) console.log(JSON.parse(JSON.stringify(data)).id)
I have the same result. Why can't I get the identifier from the input parameter?
EDIT1
I changed the parameter name to be different from the function name, as shown below:
data(spark, d){ console.log('receive ', d) console.log(JSON.parse(JSON.stringify(d)).id) }
but I still get the same result.
source share