当前位置:网站首页>Every (), map (), forearch () methods. There are objects in the array
Every (), map (), forearch () methods. There are objects in the array
2022-06-24 09:07:00 【Secret Shura】
every() Method
This is an array and an object :
Method is used to check whether all elements of the array meet the specified conditions ( Provide... Through functions ).
every() Method uses the specified function to detect all elements in the array :
If an element in the array is detected to be unsatisfied , The entire expression is returned false , And the remaining elements are no longer detected .
If all the elements satisfy this condition , Then return to true.
Be careful : every() Empty arrays are not detected .
Be careful : every() It doesn't change the original array .
<template>
<button @click="chooseButton(index)" :class="item.myShow===true?'collectTwo' : 'my_choose'" ></button>
</template>
export default{
data(){
return{
collestList:[
{
myshow:false
},
{
myshow:false
},
{
myshow:false
}
]
}
}
method:{
// Selected items
chooseButton:function(res){
// Determine whether all are selected
let myselse = this.collestList.every(item=>{
if (item.myShow==true) return true })
console.log(myselse)// Output is false
},
}
}

map() Method
effect : Process the array by specifying a function , And return the processed results in the form of a new array
Be careful : It doesn't change the original array , Just return the processed results in the form of a new array
var users = [
{
name: " Zhang Hanyun ", "email": "[email protected]"},
{
name: " Jiang Yiyan ", "email": "[email protected]"},
{
name: " Li Xiaolu ", "email": "[email protected]"}
];
var emails = users.map(function (user) {
return user.email; });
console.log(emails);
//["[email protected]", "[email protected]", "[email protected]"]
forEach() Method
forEach() Method is used to call each element of an array , And pass the element to the callback function .
Be careful : forEach() Callbacks are not performed for empty arrays .
this.collestList.forEach((value , index) => {
/// This is collestList Add inside myShow:false Field of
value['myShow1'] = false
})
/// It's like this
collestList:[
{
myshow:false,
myshow1:false
},
{
myshow:false,
myshow1:false
},
{
myshow:false,
myshow1:false
}
]
边栏推荐
- tcpdump抓包实现过程
- 【ES6闯关】Promise堪比原生的自定义封装(万字)
- Camera projection matrix calculation
- Essay - Reflection
- Opencv daily function structure analysis and shape descriptor (7) finding polygon (contour) / rotating rectangle intersection
- 关于 GIN 的路由树
- Array opposite pointer series
- Qingcloud based R & D cloud solution for geographic information enterprises
- Linux MySQL installation
- How does the tunnel mobile inspection track robot monitor 24 hours to ensure the safety of tunnel construction?
猜你喜欢

I heard that you are still spending money to buy ppt templates from the Internet?
![[quantitative investment] discrete Fourier transform to calculate array period](/img/0d/aac02463ff403fb1ff871af5ff91fa.png)
[quantitative investment] discrete Fourier transform to calculate array period

4275. Dijkstra sequence

Opencv maximum filtering (not limited to images)

From the Huawei weautomate digital robot forum, we can see the "new wisdom of government affairs" in the field of government and enterprises

uniapp 开发多端项目如何配置环境变量以及区分环境打包
![[noi Simulation Competition] geiguo and time chicken (structure)](/img/4c/ed1b5bc2bed653c49b8b7922ce1674.png)
[noi Simulation Competition] geiguo and time chicken (structure)

Opencv daily function structure analysis and shape descriptor (7) finding polygon (contour) / rotating rectangle intersection
![[Niuke] length of the last word of HJ1 string](/img/8b/6ba6506415b8112aea957ac5647121.png)
[Niuke] length of the last word of HJ1 string

What is graph neural network? Figure what is the use of neural networks?
随机推荐
Pytoch read data set (two modes: typical data set and user-defined data set)
开源之夏中选名单已公示,基础软件领域成为今年的热门申请
MySQL - SQL statement
How to configure environment variables and distinguish environment packaging for multi terminal project of uniapp development
pm2 部署 nuxt3.js 项目
MBA-day25 最值问题-应用题
[Niuke] convert string to integer
1528. 重新排列字符串
Double pointer analog
基于单片机开发的酒精浓度测试仪方案
阿里资深软件测试工程师推荐测试人员必学——安全测试入门介绍
[pytoch basic tutorial 31] youtubednn model analysis
216. combined summation III enumeration method
[e325: attention] VIM editing error
【牛客】把字符串转换成整数
Threejs glow channel 01 (unrealbroompass & layers)
A tip to read on Medium for free
Determination of monocular and binocular 3D coordinates
用VNC Viewer的方式远程连接无需显示屏的树莓派
普通人没有学历,自学编程可以月入过万吗?