Lodash.js - difference() function

A simple Lodash.js example of the difference() function, which deletes values in the first array provided by the second array.
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
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="Tizen Angular.js example"/>
    <title>Tizen lodash.js example</title>
    <script src="js/lodash.min.js"></script>
</head>
<body>
<div id="first">
</div>
<br>
<div id="second">
</div>
<script>
    var firstDiv = document.getElementById('first');
    var secondDiv = document.getElementById('second');
    var firstValue = [1,2,6,2,1,23,1,2,2134,1,1,1];
    var secondValue = [1,2];
    var result = _.difference(firstValue, secondValue);
        firstDiv.innerHTML = "From the array " + firstValue + " we delete all the values specified in another array [1,2]...";
        secondDiv.innerHTML = "...and we get: " + result;
</script>
</body>
</html>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX