How to get the class of an object in gjs?

in python there’s the function type:

>>> o=Gtk.Label()
>>> type(o)
<class 'gi.repository.Gtk.Label'>
>>> 

in c there’s G_OBJECT_GET_CLASS

how can i do that in gjs?

i found it, it’s the .constructor property:

gjs> label = new Gtk.Label
[object instance wrapper GIName:Gtk.Label jsobj@0x2bed19c7ce70 native@0x55ba539e7940]
gjs> label.constructor
[ Function: Gtk_Label ]
gjs> label instanceof label.constructor
true
gjs> 

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.