Can't access object property, even though it shows up in a console log

后端 未结 30 1801
日久生厌
日久生厌 2020-11-22 06:26

Below, you can see the output from these two logs. The first clearly shows the full object with the property I\'m trying to access, but on the very next line of code, I can\

30条回答
  •  鱼传尺愫
    2020-11-22 07:03

    I had the same issue and no solution above worked for me and it sort of felt like guess work thereafter. However, wrapping my code which creates the object in a setTimeout function did the trick for me.

    setTimeout(function() {
       var myObj = xyz; //some code for creation of complex object like above
       console.log(myObj); // this works
       console.log(myObj.propertyName); // this works too
    });
    

提交回复
热议问题