How to get a node title in Drupal 10

To get node object using node parameters,

$node = \Drupal::routeMatch()->getParameter('node');

if (!$node) {

  return;

}

$title = $node->getTitle();

Category