Chrome Debugger: What's a "PropertyBag" object?

Viewed 100

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".

enter image description here

What special kind of object is a "PropertyBag"?

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

1 Answers

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!

Related