javascript says JSON object property is undefined although it's not

后端 未结 4 575
抹茶落季
抹茶落季 2021-01-18 00:02

I have a json-object, which I print to the screen (using alert()-function):

alert(object);

Here is the result:

Then I want

4条回答
  •  清歌不尽
    2021-01-18 00:46

    You will need to assign that to a var and then access it.

    var object = {id: "someId"};
    console.log(object);
    alert(object["id"]);

提交回复
热议问题