How to get the product type like configurable on PDP and PLP pages in Magento 2?

In PLP and PDP page, use the $product object to get the product type.

Syntax:


/**
 * @return configurable, simple, grouped, virtual, downloadable, bundle or gift card product type
 */
$product->getTypeId()
Thank you!