是否检查一个js变量是否为d3选择? [英] Is there to check if a js variable is a d3 selection?
本文介绍了是否检查一个js变量是否为d3选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些变量进入我的函数。
I some variables coming into my function.
如果第一个是d3选择,我想使用它,否则我想使用默认选择。
If the first of these is a d3 selection I want to use it, otherwise I want to use a default selection.
如何检查变量是否为d3选择?
How do I check if a variable is a d3 selection or not?
推荐答案
要检查变量 sel
是否为d3.selection:
To check if variable sel
is a d3.selection:
var isselection = sel instanceof d3.selection;
这篇关于是否检查一个js变量是否为d3选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文