toolbar button check

Is there a way to check if a buttonselect exists on the toolbar by the id that it should have? If there are no buttons under the buttonselect, I am not showing it at all. But I need a way to check it it does exists so some other code does not execute that depends on the buttonselect.

Try to use getType method. If there is not such an item, the method will return null:

var type = toolbar.getType(itemId);