drupal 8 check if current page is node

JavaScript
$node = \Drupal::routeMatch()->getParameter('node');
if ($node instanceof \Drupal\node\NodeInterface) {
  // It's a node!
}
Source

Also in JavaScript: