[Home] >  DOM >  Check if an element is a descendant of another

Check if an element is a descendant of another

JavaScript version

const isDescendant = (child, parent) => parent.contains(child);

TypeScript version

const isDescendant = (child: Node, parent: Node): boolean => parent.contains(child);