-
Notifications
You must be signed in to change notification settings - Fork 0
/
L5.6.html
47 lines (40 loc) · 1.26 KB
/
L5.6.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
43
44
45
46
47
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>回调函数</title>
<script>
function checkColor(element, index, array){
return (element >=0 && element < 256);
}
function checkCount(element,index,array){
return (element.length ==3);
}
function testingCallbacks(){
var colors = new Array();
colors[0] = [0,262,255];
colors[1] = [255,255,255];
colors[2] = [255,0,0];
colors[3] = [0,255,0];
colors[4] = [0,0,255];
colors[5] = [-5,999,255];
colors[6] = [255,255,1204556];
var testedColors = new Array();
for(var i in colors){
testedColors[i] =colors[i].filter(checkColor);
}
document.writeln("<h3>First Check</h3>");
for(i in testedColors){
document.writeln(testedColors[i] + "<br/>");
}
var newTested = testedColors.filter(checkCount);
document.writeln("<br/><h3>Second</h3>");
for(i in newTested){
document.writeln(newTested[i] + "<br/>");
}
}
</script>
</head>
<body onload="testingCallbacks()">
</body>
</html>