想知道这两层循环中i,和j的变化,里外层循环是怎么走的?

               for (let i = 0; i < this.temp1.length; i++) {
                        let found = false;                        for (let j = 0; j < combination_name_list.length; j++) {                            if (combination_name_list[j] == this.temp1[i].name) {
                                found = true;
                            }                    if (j == combination_name_list.length - 1 && found == false) {                                this.combination.push({                                    "name": this.temp1[i].name,                                    "rows1": this.temp1[i].rows,                                    "rows2": [],                                    "type": this.temp1[i].type
                                });
                            }
                        }
                    }

想知道这两层循环中i,和j的变化,里外层循环是怎么走的,以及这段代码的意思,只能看懂一半!


慕无忌1623718
浏览 593回答 1
1回答

一只甜甜圈

这个是取差集var&nbsp;temp1&nbsp;=&nbsp;[{name:"a"},{name:"d"},{name:"c"}];var&nbsp;combination_name_list&nbsp;=&nbsp;['a']; //结果var&nbsp;combination&nbsp;=&nbsp;[{name:"d"},{name:"c"}];combination_name_list&nbsp;中存的是&nbsp;temp1&nbsp;的&nbsp;name就是拿着&nbsp;temp1&nbsp;中 第一项 去&nbsp;combination_name_list&nbsp;中找 找到了 不操作 ,没找到 将这一项加进 新数组combination以此类推 第二项 。。。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript