我有一个具有多个属性的对象,其中一个是值为 1. 的 'lane' console.log(myObject)
,显示该属性及其值在那里。但是,如果我尝试访问它myObject.lane
,它是“未定义的”。另外-如果我用 打印对象的键Object.keys(myObject)
,则数组具有除“lane”之外的所有属性!我真的不知道还能做什么,或者什么样的问题会导致这种情况。
//actual code (in a React Redux reducer... which shouldn't matter in my opinion)
console.group("What is happening?");
console.log("myObject", myObject);
console.log(
"you can clearly see that 'lane' in is myObject with value of number 1."
);
console.log("Object.keys(myObject)", Object.keys(myObject));
console.log("But somehow, 'lane' is not a key in myObject");
console.log("MyObject again", myObject);
console.log("myObject.lane is undefined? : ", myObject.lane);
console.log("Other keys work, like myObject.alpha : ", myObject.alpha);
console.groupEnd();
这是控制台输出的图片。
什么会导致对象控制台记录属性及其值,但实际上不是键?