在javascript中实现以下功能的有效方法
boolean isChild(node1, node2)
where,
node1 = Considered parent node
node2 = Considered child node
function returns true if node2 is a child of node1 else false
答案 0 :(得分:6)
function isChild(node1, node2) {
return node2 && node2.parentNode === node1;
}