时间:2022-10-29 11:23:09 | 栏目:JavaScript代码 | 点击:次
在我们的日常开发中 不免会有很多需要处理数据的方法 本节主要说一说foreach和some的使用??不多说把代码编辑器打开??

var geyao = ['歌谣', '很帅', '很强']
geyao.forEach((currentValue, index, arr, thisValue) => {
console.log(currentValue, 'currentValue')
console.log(index, 'index')
console.log(arr, 'arr')
console.log(thisValue, 'thisValue')
})
小结:

//item 当前元素每一项的值
var geyao=['歌谣',"很帅","很强"]
var geyao1 = geyao.some((item)=>{
return item='歌谣'
})
console.log(geyao1,"geyao1")
注意:some() 不会对空数组进行检测。
注意:some() 不会改变原始数组。