TypeOf

TypeOf::class[symbol]
checks, if symbol is class or a class derived directly or indirectly from class. While TypeOf tests classes, InstanceOf tests objects.
This loads the package.
In[1]:=
Click for copyable input
The next cell generates a tiny class hierarchy.
In[2]:=
Click for copyable input
We now test for types. grandchild and greatgrandchild have child as (indirect) parent and are therefore also of type child. Analogously, greatgrandchild is also a grandchild.
In[3]:=
Click for copyable input
Out[3]=
Out[3]=
Out[3]=
Objects are not recognized by TypeOf.
In[4]:=
Click for copyable input
Out[4]=
Any other "class" yields False.
In[5]:=
Click for copyable input
Out[5]=
Please observe that the ::-operator acts on the scond argument rather quickly. Therefore, the following fails.
In[6]:=
Click for copyable input
Out[6]=