How to use menu_get_object()? I was using menu_get_object() to load node information in Drupal 6.

if ($node = menu_get_object()) {
    // Get the nid
    $nid = $node-&gt;nid;
  }


Since menu_get_object() is deprecated in Drupal 8, I was using the following code. 

if ($node_id = \Drupal::request()-&gt;attributes-&gt;get('node')) { #menu_get_object()   
    //load all the information of the node
    $node = node_load($node_id);
  }
  echo '&lt;pre&gt;';print_r($node);exit();echo '&lt;/pre&gt;'; //its okay
  echo $node-&gt;type-&gt;value; //not working


This is not getting the node values, but printing the node information's in array. How do I resolve this ?

UPDATE

I am getting all other values like $node-&gt;title-&gt;value and $node-&gt;nid-&gt;value, but not $node-&gt;type-&gt;value.
See
https://drupal.stackexchange.com/a/202185/45409

In Drupal 8, you can get url arguments based on what's in the routing.

To get the id alone:

$nid = \Drupal::routeMatch()-&gt;getRawParameter('node');


If you plan to load the node object, you can simply get it this way:

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


To find the parameter names, you can use:

$possible_parameters = \Drupal::routeMatch()-&gt;getParameters();


To find the node type, use:

$node-&gt;bundle();