Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个随机的 DOM 节点,我想确定它是否是一个svg元素,即从SVGElement构造函数继承。我知道我可以通过调用__proto__节点来遍历原型链,但是是否有内置方法来确定这一点?
svg
SVGElement
__proto__
有一个专门的instanceof操作符检查一个对象的原型链中是否有构造函数的原型:
instanceof
node instanceof SVGElement
但是,鉴于您实际上不能这样做new SVGElement()(与所有节点构造函数一样),这可能无法在所有浏览器中可靠地工作。
new SVGElement()
这是继我之前回答的请求之后的结果。但我无法理解的下一个问题是,为什么当我的参数报告一条记录时,我会收到一条消息,即谷歌搜索/SO 搜索建议我需要使用 update_all。
2 string - Bash 中的字符串布尔值