简体   繁体   中英

Chrome Debugger: What's a “PropertyBag” object?

Using the Chrome Debugger in the following way:

console.dir(element);

On the console the data-type is called a "PropertyBag". I would have expected "Object".

在此输入图像描述

What special kind of object is a "PropertyBag"?

I have never read that term in JavaScript before ...

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. For example, the PropertyBag class exists in 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. 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM