亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

javascript數(shù)組中的map方法和filter方法

 更新時(shí)間:2022年03月15日 09:35:31   作者:前端歌謠  
這篇文章主要介紹了javascript數(shù)組中的map方法和filter方法,文章內(nèi)容介紹詳細(xì),具有一定的參考價(jià)值,需要的小伙伴可以參考一下,希望對(duì)你的學(xué)習(xí)有所幫助

一、map方法

1編輯器

編輯器搞出來 一起研究研究數(shù)組中的map方法:

2代碼部分

var geyao=['歌謠',"很帥","很強(qiáng)"]
? ? geyao.map((currentValue,index,arr,thisValue)=>{
? ? ? ? console.log(currentValue,"currentValue")
? ? ? ? console.log(index,"index")
? ? ? ? console.log(arr,"arr")
? ? ? ? console.log(thisValue,"thisValue")
? ? })

3運(yùn)行結(jié)果

小結(jié):

currentvalue 當(dāng)前元素的值 index 索引值 arr 當(dāng)前元素屬于的數(shù)組對(duì)象 thisValue 對(duì)象作為該執(zhí)行函數(shù)的回調(diào)

二、filter方法 

1編輯器

 編輯器搞出來 一起研究研究數(shù)組中的map方法:

2代碼

var geyao=['歌謠',"很帥","很強(qiáng)"]
? var geyao1 = geyao.filter((currentValue,index,arr,thisValue)=>{
? ? ? ? console.log(currentValue,"currentValue")
? ? ? ? console.log(index,"index")
? ? ? ? console.log(arr,"arr")
? ? ? ? console.log(thisValue,"thisValue")
? ? ? ? return currentValue==='歌謠'
? ? })
? ? console.log(geyao1,"geyao1")

3運(yùn)行結(jié)果

小結(jié):

currentvalue 當(dāng)前元素的值 index 索引值 arr 當(dāng)前元素屬于的數(shù)組對(duì)象 thisValue 對(duì)象作為該執(zhí)行函數(shù)的回調(diào) 形成一個(gè)新數(shù)組 形成的是過濾后的值 和map相似

到此這篇關(guān)于javascript數(shù)組中的map方法和filter方法的文章就介紹到這了,更多相關(guān)map和filter方法內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論