亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

想知道這兩層循環中i,和j的變化,里外層循環是怎么走的?

想知道這兩層循環中i,和j的變化,里外層循環是怎么走的?

慕無忌1623718 2018-09-23 20:17:21
               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的變化,里外層循環是怎么走的,以及這段代碼的意思,只能看懂一半!
查看完整描述

1 回答

?
一只甜甜圈

TA貢獻1836條經驗 獲得超5個贊

這個是取差集

var temp1 = [{name:"a"},{name:"d"},{name:"c"}];var combination_name_list = ['a'];

//結果var combination = [{name:"d"},{name:"c"}];

combination_name_list 中存的是 temp1 的 name

就是拿著 temp1 中 第一項 去 combination_name_list 中找 找到了 不操作 ,沒找到 將這一項加進 新數組combination以此類推 第二項 。。。


查看完整回答
反對 回復 2018-09-23
  • 1 回答
  • 0 關注
  • 614 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號