I have a random DOM node and I want to determine whether it is an svg element, namely that is inherits from the SVGElement constructor. I know I could just walk up the prototype chain by calling __proto__ on the node, but is there a built in method to determine this?
I have a random DOM node and I want to determine whether it is
Share
There is the dedicated
instanceofoperator which checks whether an object has a constructor’s prototype in its prototype chain:However, given that you cannot actually do
new SVGElement()(as with all node constructors), this may not work reliably across all browsers.