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

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

想知道continue在這里起什么作用,去掉得話應該如何改寫?

想知道continue在這里起什么作用,去掉得話應該如何改寫?

嚕嚕噠 2018-09-01 20:10:01
   var my_department = [];                    for (var i = 0; i < aggregations.all_outdept_name.buckets.length; i++) {                        if (aggregations.all_outdept_name.buckets[i].key == '') continue;                        var department_obj = {                             value: aggregations.all_outdept_name.buckets[i].key,                            label: aggregations.all_outdept_name.buckets[i].key,                             count: aggregations.all_outdept_name.buckets[i].doc_count                         }                         my_department.push(department_obj);                     }                     _this.department = my_department;
查看完整描述

1 回答

?
慕森王

TA貢獻1777條經驗 獲得超3個贊

continue的意思是跳過這輪循環,馬上開始下輪循環。 在你的代碼中,執行continue,那么if語句continue之后的都不執行了。 i++后執行新的一輪循環判斷。

若想去掉,你就反著寫唄,即滿足xxx條件才執行if continue下面的語句

for (var i = 0; i < aggregations.all_outdept_name.buckets.length; i++) {    if (!(aggregations.all_outdept_name.buckets[i].key == '')){        var department_obj = {            value: aggregations.all_outdept_name.buckets[i].key,            label: aggregations.all_outdept_name.buckets[i].key,            count: aggregations.all_outdept_name.buckets[i].doc_count
        }
        my_department.push(department_obj);
    }
}


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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