[英]Chrome Debugger: What's a “PropertyBag” object?
Using the Chrome Debugger in the following way: 通过以下方式使用Chrome调试器:
console.dir(element);
On the console the data-type is called a "PropertyBag". 在控制台上,数据类型称为“PropertyBag”。 I would have expected "Object".
我原以为“对象”。
What special kind of object is a "PropertyBag"? 什么特殊的物体是“PropertyBag”?
I have never read that term in JavaScript before ... 我之前从未在JavaScript中读过这个术语......
As you said in the above comments, you are using some code written by somebody else (or a custom framework) and element
is just an instance of a custom class. 正如您在上面的注释中所说,您使用的是其他人(或自定义框架)编写的代码,而
element
只是自定义类的一个实例。 For example, the PropertyBag class exists in cesiumjs . 例如,PropertyBag类存在于cesiumjs中 。
If the object is an instance of a class (not a simple object, really a class with a constructor), if you use console.log
on that item, you'll get the class name in the console (at least in Chrome) and a little arrow to expand it. 如果对象是类的实例(不是简单对象,实际上是带有构造函数的类),如果在该项上使用
console.log
,您将在控制台中获取类名(至少在Chrome中)和一个小箭头来扩展它。 You can copy/paste the following code in the console to test the behavior. 您可以在控制台中复制/粘贴以下代码以测试行为。
class User {
constructor(name) {
this.name = name;
}
sayHi() {
alert(this.name);
}
}
let user = new User("John");
console.log(user);
Cheers! 干杯!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.