4

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

michael.zech
  • 3,524
  • 5
  • 19
  • 37
  • 2
    Are you sure you are not using some code from somebody else and `element` is just an instance of a custom class? For example, the `PropertyBag` class exists in [cesiumjs](https://cesiumjs.org/Cesium/Build/Documentation/PropertyBag.html). – Adrian Pop Jan 16 '19 at 10:04
  • @AdrianPop That might be the reason. I use a Framework indeed: SAP OpenUI5 / OPA5. Haven't known that the Chrome Debugger displays custom classes with their individual class-name. Thought it would display JavaScript default names (Object, Array, etc.) only. – michael.zech Jan 16 '19 at 10:10
  • 1
    If the object is an instance of a class (not a simple object, really a class), if you console.log that item, you'll get the class name in the console, at least in Chrome. Just tested it again to be sure. – Adrian Pop Jan 16 '19 at 10:14
  • Indeed, [no such term](https://cs.chromium.org/search/?q=%5CbPropertyBag%5Cb+case:yes) in chrome's source. – wOxxOm Jan 16 '19 at 10:17
  • @AdrianPop Thanks a lot. I you like make your comment an answer. I will accept it. – michael.zech Jan 16 '19 at 10:29

1 Answers1

2

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!

Adrian Pop
  • 1,541
  • 4
  • 21
  • 30