当前位置:网站首页>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
}
]
边栏推荐
- Unable to change the virtual machine power status and report an error solution
- Change SSH port number
- 【Pytorch基础教程31】YoutubeDNN模型解析
- Target detection series fast r-cnn
- Spark - LeftOuterJoin 结果条数与左表条数不一致
- 2022-06-23:给定一个非负数组,任意选择数字,使累加和最大且为7的倍数,返回最大累加和。 n比较大,10的5次方。 来自美团。3.26笔试。
- Array opposite pointer series
- Digital cloud released the 2022 white paper on digital operation of global consumers in the beauty industry: global growth solves marketing problems
- [use picgo+ Tencent cloud object to store cos as a map bed]
- GradScaler MaxClipGradScaler
猜你喜欢

深入了解 border

Squid proxy application

数云发布2022美妆行业全域消费者数字化经营白皮书:全域增长破解营销难题

Opencv daily function structure analysis and shape descriptor (7) finding polygon (contour) / rotating rectangle intersection

KaFormer个人笔记整理

MySQL | store notes of Master Kong MySQL from introduction to advanced

2022-06-23:给定一个非负数组,任意选择数字,使累加和最大且为7的倍数,返回最大累加和。 n比较大,10的5次方。 来自美团。3.26笔试。

【E325: ATTENTION】vim编辑时报错

Squid代理服务器应用

How to configure environment variables and distinguish environment packaging for multi terminal project of uniapp development
随机推荐
Jincang KFS replicator installation (oracle-kes)
12、 Demonstration of all function realization effects
4274. suffix expression
Spark - the number of leftouterjoin results is inconsistent with that of the left table
Target detection series fast r-cnn
“不平凡的代理初始值设定不受支持”,出现的原因及解决方法
1528. 重新排列字符串
Opencv daily function structure analysis and shape descriptor (7) finding polygon (contour) / rotating rectangle intersection
Sword finger offer 55 - I. depth DFS method of binary tree
Huawei Router: GRE Technology
Unable to change the virtual machine power status and report an error solution
[e325: attention] VIM editing error
随笔-反思
One article explains in detail | those things about growth
【LeetCode】387. 字符串中的第一个唯一字符
Pytorch读入据集(典型数据集及自定义数据集两种模式)
怎么把mdf和ldf文件导入MySQL workbench中
Become an IEEE student member
MySQL | view notes on Master Kong MySQL from introduction to advanced
听说你还在花钱从网上买 PPT 模板?