-
Notifications
You must be signed in to change notification settings - Fork 1
/
lodash.html
103 lines (103 loc) · 2.35 KB
/
lodash.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js"></script>
<script type="text/javascript">
// let index = _.indexOf([1, 2, 1, 2], undefined);
// console.log(index)
//
const last = _.last('');
console.log(last)
var songs = [
{
name: "羽根",
artist: "air"
}, {
name: "羽根",
artist: "airports"
}, {
name: "晴天",
artist: "周杰伦"
}, {
name: "晴天",
artist: "周杰伦"
}, {
artist: "周杰伦",
name: "晴天"
}
];
let u = _.uniqBy(songs, 'name')
// console.log(u)
var original = [
{
label: 'private',
id:1,
value: '[email protected]'
}, {
label: 'school',
id:2,
value: '[email protected]'
}
];
var update = [
{
label: 'private',
value: '[email protected]',
cName: 'cName'
}, {
label: 'school',
value: '[email protected]',
cName: 'cName'
},
{
label: 'school',
value: '[email protected]',
cName: 'cName'
}
];
var result = _.merge(original, update);
// console.log(original);
var s = [
{
name: "羽根",
artist: "air"
}, {
name: "羽根",
artist: "air"
}, {
name: "晴天",
artist: "周杰伦"
}, {
name: "晴天",
artist: "周杰伦"
}, {
artist: "周杰伦",
sex: "晴天"
}, {
artist: "周杰伦",
name: "晴天"
}
];
let rv = s.filter(item => item.name).length
// console.log(rv)
var fruits = ['Apple', 'Banana', 'Orange', 'Celery'];
var left = _.remove(fruits, function (n) {
return n == 'Apple'
})
// console.log(left)
// console.log(fruits)
var array = [1, 2, 3, 4];
var evens = _.remove(array, function (n) {
return n % 2 == 0;
})
// console.log(array);
// => [1, 3]
// console.log(evens);
//------//
</script>
</body>
</html>