-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path箭头函数实践.html
42 lines (39 loc) · 1.05 KB
/
箭头函数实践.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>箭头函数实践</title>
<style>
div{
width: 200px;
height: 200px;
background: skyblue;
}
</style>
</head>
<body>
<div id="ad"></div>
<script>
let ad = document.getElementById('ad');
ad.addEventListener("click",function(){
// let _this = this
setTimeout(()=>{
// _this.style.background = 'pink'
this.style.background = 'pink'
},2000)
})
const arr = [1,6,9,10,100,25]
// const result = arr.filter(function(item){
// if(item % 2 === 0){
// return true;
// }else{
// return false;
// }
// });
const result = arr.filter(item => item % 2 === 0);
console.log(result);
</script>
</body>
</html>