即使第一个“if语句”进入
,“for”子句也不会中断function getNodeByName(array, name) {
var mediaNode = null;
for (var i = 0; i < array.children.length; i++) {
if(array.children[i].name === name) {
mediaNode = array.children[i];
console.log(array.children[i]);
break;
}
if(array.children[i].children !== null) {
getNodeByName(array.children[i], name);
}
}
return mediaNode;
}