How can I determine if currently in object mode or component mode?

I want to carry out different commands depending on whether the user is in object mode or component. I am having trouble determining this context.
Searching around, I came across this post, How to check component mode - Maya - Highend3d Artists Discussion Forums.

After experimenting with the suggested command, I am not sure if its the right command. I can get a correct answer (0 or 1) but I have to check vertex mode, edge mode etc etc:

//selectType -ocm -q -v;
//selectType -q -cv;
//selectType -q -surfaceEdge;
//selectType -q -objectComponent -vertex;
selectType -q -objectComponent -surfaceFace;

I would just like to check if in object mode or not so I can proceed with simple if condition. I asked chatGPT and I got an answer using a flag that does not exist.