-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunderscore.html
More file actions
65 lines (49 loc) · 1.31 KB
/
underscore.html
File metadata and controls
65 lines (49 loc) · 1.31 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<!-- <script src="underscore.js"></script> -->
<!-- <script src="learn-underscore.js"></script> -->
<script src="m.js"></script>
</head>
<body>
</body>
</html>
<script>
/*_.each(a, function(i,index,collection) {
console.log(index)
},window)*/
/* 伪造数组方法
var eles = {
length: 0,
add: function(elem){
Array.prototype.push.call(this,elem)
},
get: function(id){
this.add(document.getElementById(id))
},
k: 0
}
eles.get( "id" )*/
/*var arr =_.map({one: 1, two: 2, three: 3},function(i){
console.log(i)
});*/
/*var even = _.find([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
/*var even = _.find([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
*/
/*var k =_.every([2, 1, 3, 4], function(i){
return i > 1;
});*/
/*console.log(_.some([0, -1,2], function(i){
return i > 1;
}))*/
//console.log(_.contains({name: 'box'}, 'box'))
/*var result = _.groupBy([1.3, 2.1, 2.4], function(num){ return Math.floor(num);})
console.log(result)*/
//console.log(_.shuffle({name: 3,age:12, to:4}))
console.log(_.mapObject({start: 5, end: 12}, function(val, key) {
return val + 5;
}))
/*console.log(_.shuffle({name: 3,age:12, to:4}))*/
</script>