If I have some var,
And need to know if it Bitmap.
How I can check it?
For example, I want check if obj is Bitmap or Container or regular object.
All the ZIM objects have a type property.
const b = new Bitmap();
zog(b.type); // Bitmap
const s = new Slider();
zog(s.type); // Slider
For an object literal, we usually compare its constructor
if (obj.constructor == {}.constructor) // object literal
Thanks!
And if its my class that extend Zim Container ?
It will be a "Container" unless you set the type in your class after you call the Container super(). So that is how we do it when we extend, we set the type after calling the super constructor.
Thanks!
1 Like