I am new to javascript.
class ExpansionPath {
expandPipelineNodes()
{
this.expandPipelineNode(this._rootNodes);
}
expandPipelineNode(node)
{
let bPipeline = false
_.each(node.children,function(child){
bPipeline |= this.expandPipelineNode(child);
})
...
}
}
When I call the function expandPipelineNodes, it calls expandPipelineNode(node) which is fine. But when it goes inside the foreach loop, the program crashes. I have debugged the program and it showed that this becomes to undefined in the forEach loop. I also tried the following code:
node.children.forEach(function(child){
bPipeline |= this.expandPipelineNode(child);
})
But the problem remains. How can I solve this problem in javascript?