在我之前:

      for (var i = 0; i < t1Children.length; i++) {
          return checkIdentical( t1Children[i], t2Children[i] );
      }


但是我不知道如何使用for循环模式将每个“ i”的&&条件链接在一起。

下面是我想要的方式,但是我需要继续手动添加t2Children [2],[3]等。

      return ( ( checkIdentical( t1Children[0], t2Children[0] ) ) && ( checkIdentical( t1Children[1], t2Children[1] ) ) );


如何以一种可以将&&链接在一起的方式进行迭代?有什么建议么?

最佳答案

这个怎么样?

var result = true;
for (var i = 0; i < t1Children.length; i++) {
     result = result && checkIdentical( t1Children[i], t2Children[i] );
}

09-25 15:05