How to get field type programmatically in Drupal 8.

I need to get a field type programmatically.
<?php

    $field_def
= $node->getFieldDefinition($field_name)->getType();

?>
Tags