How can I get the id name of a submenu?

There’s a template script called ui_menu.py, and in line 19, there’s this line:

layout.operator_menu_enum("object.select_by_type", property = "type", text="Select All by Type...")


I thought I could find the id name “object.select_by_type” by hovering over Select -> Select All by Type… in the 3D viewport, but when I did, I couldn’t see any grayish popup saying something like “Python: object.select_by_type()”. How can find the id name of submenus like this one?

I did a lot of experimenting, and I found the answer I was looking for. It involves self.layout.operator_menu_enum() and self.layout.menu(). I posted my answer on Blender Stack Exchange.