title: Get the type of element in a selection
body: <p>How can I find the underlying element of a d3 selection?</p>
  
  <p>I tried <code>d3.select(elem).node()</code> gives the entire node, not just the element. I also checked (in v5) that there is a <code>_groups</code>, and I could potentially derive the element from there. But is there a more direct method?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>For e.g.</p>
  
  <pre class="lang-javascript prettyprint-override"><code>var svg = d3.select('svg');
  renderChart(svg);
  
  ...
  
  var g = d3.select('g');
  renderChart(g);
  
  
  function renderChart(element){
    // I want to find out here if the element (selection) passed
    // is "svg" or a "g", and then take appropriate action
  
    // element.node() is giving me the whole object -- not just that particular element
  
    if (&lt;tbd&gt; == "svg"){
       // take action here
    }
  }
  </code></pre>
  
  <p><code>element.node()</code> in the above example returns an object. For e.g. in case of <code>svg</code>, it looks like this in Chrome console</p>
  
  <p><a href="https://i.stack.imgur.com/zJVmk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zJVmk.png" alt="enter image description here"></a></p>
  
  <p>In my real case, I have the main chart that I have to draw on SVG element, but I need to provide clickable actions on that chart, which will run the same chart code, but with different data to generate a "sub chart" and append it as "g" element.</p>
  
  <p>Thank you!</p>