第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

JavaScript 箭頭函數(shù)中的問題

JavaScript 箭頭函數(shù)中的問題

SMILET 2021-12-23 18:06:42
我是新手我已經(jīng)在此鏈接中下載了一些源 https://github.com/the-road-to-learn-react/react-redux-example 我在文件 src/app.js 第 4 行中有一些問題const applyFilter = searchTerm => article =>  article.title.toLowerCase().includes(searchTerm.toLowerCase());為什么這不能與const applyFilter = searchTerm => article =>{  article.title.toLowerCase().includes(searchTerm.toLowerCase());} 或者const applyFilter = searchTerm => {article =>  article.title.toLowerCase().includes(searchTerm.toLowerCase());}并在第 14 行調(diào)用函數(shù)時(shí)articles.filter(applyFilter(searchTerm))const applyFilter = searchTerm => article =>  article.title.toLowerCase().includes(searchTerm.toLowerCase());這在我看來是在箭頭函數(shù)內(nèi)調(diào)用箭頭函數(shù)?他們?cè)趺茨馨?var 'article' 放進(jìn)去?
查看完整描述

1 回答

?
LEATH

TA貢獻(xiàn)1936條經(jīng)驗(yàn) 獲得超7個(gè)贊

箭頭函數(shù)語法有點(diǎn)像這樣


(a) => b(a);


is equivalent to


function(a) {

    return b(a);

}

但是,當(dāng)您添加{}到箭頭函數(shù)時(shí),它會(huì)改變含義:


(a) => { b(a); }


is equivalent to


function(a) {

    b(a); 

    // notice that this doesn't actually return anything, 

    // it just calls a function and does nothing with the result

}

所以加括號(hào)的時(shí)候要加return語句


(a) => { return b(a); }


查看完整回答
反對(duì) 回復(fù) 2021-12-23
  • 1 回答
  • 0 關(guān)注
  • 154 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)