Returns true if possibleChild is contained within maxDepth children of parent node. By default only looks at immediate children (maxDepth = 0).

// Just check parentNode for childNode
Trees.hasChild(parentNode, childNode);
// See if parentNode or parentNode's parents have childNode
Trees.hasChild(parentNode, childNode, 1);
// Use custom equality function, in this case comparing on name field
Trees.hasChild(parentNode, childNode, 0, (a, b) => a.name === b.name);
  • Type Parameters

    • T

    Parameters

    Returns boolean