Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在复杂的javaScript数组对象中搜索_Javascript_Angularjs_Lodash - Fatal编程技术网

如何在复杂的javaScript数组对象中搜索

如何在复杂的javaScript数组对象中搜索,javascript,angularjs,lodash,Javascript,Angularjs,Lodash,我有点困惑。我在指令中有以下代码: NavTabsDirective.prototype.addPane=函数(窗格){ if(!.isObject(pane)| |“pane”!==pane.constructor.name){ 抛出新类型错误(“窗格必须是窗格的实例”); } 如果(u.isUndefined(this.FirstPane)){ this.FirstPane=窗格; } this.Panes[pane.name]=窗格; };在这里检查了几个线程后,找到了一个解决方案:

我有点困惑。我在指令中有以下代码:

NavTabsDirective.prototype.addPane=函数(窗格){
if(!.isObject(pane)| |“pane”!==pane.constructor.name){
抛出新类型错误(“窗格必须是窗格的实例”);
}
如果(u.isUndefined(this.FirstPane)){
this.FirstPane=窗格;
}
this.Panes[pane.name]=窗格;

};在这里检查了几个线程后,找到了一个解决方案:

for(让窗格在此.Panes中){
if(this.Panes[pane].isValid==false){
无效=真;
打破
}
}
var Panes=[“你好”,“世界”];
var PanesLength=Panes.length;
对于(变量i=0;i}
除非
窗格。name
是此窗格中的数字。窗格不是数组,而是对象,您可以使用其键并将其减小为值:

const result = Object.keys(this.Panes).reduce(
  (all,key)=>all && this.Panes[key].isValid,
  true
)

昨晚我想出了一个类似的解决方案,看看我自己的答案。我必须稍微调整它,并传回无效选项卡的数组,不仅仅是状态,而是用于循环。