Skip to content

Commit 5abdac3

Browse files
committed
arrays and its method
1 parent efe757d commit 5abdac3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

revision/rev2.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,36 @@ console.log(obj1.name)
6666
//obj destructuring
6767
const {name}=obj1
6868
console.log(name)
69+
70+
//arrays
71+
72+
//foreach
73+
var arr=["mak","pet",2,{model:10,color:"white"},[a,b,c]]
74+
arr.forEach((item)=>{
75+
console.log(item)
76+
})
77+
78+
//map
79+
var arr=[1,"hash"]
80+
const newarr=arr.map((item)=>{
81+
return item
82+
})
83+
console.log(newarr)
84+
85+
//filter
86+
var arr1=[1,2,3,4,5,6,7,8,9,10]
87+
const newarr1=arr1.filter((item)=>{
88+
if(item<=5)
89+
return item
90+
})
91+
console.log(newarr1)
92+
93+
//find
94+
var arr2=[3,2,4,5,2]
95+
var newarr2=arr2.find((item)=>{
96+
if(item==2){
97+
return item
98+
}
99+
})
100+
101+
console.log(newarr2)

0 commit comments

Comments
 (0)