Is there to check if a js variable is a d3 selection?

d3.js, javascript

Solution

To check if variable `sel` is a d3.selection:

var isselection = sel instanceof d3.selection;

Problem

I some variables coming into my function. If the first of these is a d3 selection I want to use it, otherwise I want to use a default selection. How do I check if a variable is a d3 selection or not?

Original source