Get labels of view modes in Drupal 8
Drupal 8 services are essentially helpful objects (tools), which live inside the services container (tool belt). Calling a service returns an object, essentially providing a clear path to the helper methods within that class. As previously answered, EntityDisplayRepository class contains various methods, specifically one that will return an array of entity view modes (see a list of available methods). By calling \Drupal::service('entity_display.repository') and storing it in a variable, you now have an object that you can then call EntityDisplayRepository methods from, which in your case, is to return 'node' view modes.

/**
 * Implements hook_preprocess_page().
 *
 * This function is called before the page is rendered.
 */
function modulename_preprocess_page(&amp;$vars) {
  // call the entity service.
  $nodeEntity = \Drupal::service('entity_display.repository');

  // call the necessary method in order to return 'node' view modes.
  $nodeEntity-&gt;getViewModes('node');

  // one line: \Drupal::service('entity_display.repository')-&gt;getViewModes('node');
}