欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript數組中的map方法和filter方法

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

一、map方法

1編輯器

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

2代碼部分

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

3運行結果

小結:

currentvalue 當前元素的值 index 索引值 arr 當前元素屬于的數組對象 thisValue 對象作為該執(zhí)行函數的回調

二、filter方法 

1編輯器

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

2代碼

var geyao=['歌謠',"很帥","很強"]
? 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運行結果

小結:

currentvalue 當前元素的值 index 索引值 arr 當前元素屬于的數組對象 thisValue 對象作為該執(zhí)行函數的回調 形成一個新數組 形成的是過濾后的值 和map相似

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

相關文章

最新評論