我正在使用ExtJs
,我想获得所有Stores
(应用程序的状态)的快照,所以我想我将遍历根Stores
并收集每个data
属性(前提是该值本身不是ExtJs
Store
)。
如果我检查开发人员控制台,我可以看到我想要的普通旧对象没有前缀constructor
,但是Stores
(ExtJs
用来处理状态的类)前缀为constructor
。
我最初认为前缀为constructor
与对象示例化的方式有关,但我无法使用以下任何一种方法来重现constructor
前缀。
> (function() {return {}})()
< {}
> class test {}
< undefined
> new test()
< test {}
> class test2 extends test{}
< undefined
> new test2()
> test2 {}
> new (function() {})
< {}
> function test3() {}
< undefined
> new test3()
< test3 {}
> Object.fromEntries(Array(20).fill(0).map((_, i) => [`${i}_someproperty`, "yeet"]))
< {0_someproperty: "yeet", 1_someproperty: "yeet", 2_someproperty: "yeet", 3_someproperty: "yeet", 4_someproperty: "yeet", …}
> {}
< {}
> (function(){return {}})()
< {}
这意味着什么,或者如何检查Chrome开发人员控制台是否为对象指定了constructor
前缀?
1条答案
按热度按时间sf6xfgos1#
我不熟悉ExtJS,但在我看来,这很可能是某种泛型子类创建的结果,使用的函数碰巧总是命名为
constructor
,例如。在这种情况下,对象在控制台/检查器中的类型位置显示为“constructor”: