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

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

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ù)時articles.filter(applyFilter(searchTerm))const applyFilter = searchTerm => article =>  article.title.toLowerCase().includes(searchTerm.toLowerCase());這在我看來是在箭頭函數(shù)內(nèi)調(diào)用箭頭函數(shù)?他們怎么能把 var 'article' 放進去?
查看完整描述

1 回答

?
LEATH

TA貢獻1936條經(jīng)驗 獲得超7個贊

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


(a) => b(a);


is equivalent to


function(a) {

    return b(a);

}

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


(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

}

所以加括號的時候要加return語句


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


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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