Node1 treeDFS let dfs = function (node) { let values = [node.value]; node.children.forEach((n) => { values = values.concat(dfs(n)); }); return values; }; let Node = function (value) { this.value = value; this.children = []; }; Node.prototype.addChild = function (child) { this.children.push(child); return child; }; let root = new Node(1); let rootChild1 = root.addChild(new Node(2)); let rootChild2 = root.addCh.. 2022. 6. 2. 이전 1 다음