Lodash.js – without() function

A simple Lodash.js example of the without() function, which will dispose of the specified values.
<!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 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,3,4,3,2,1,2,1,3];

        firstDiv.innerHTML = "Having an array:<br><br>";
        firstDiv.innerHTML += JSON.stringify(firstValue);

    var result = _.without(firstValue,1,2);

        secondDiv.innerHTML = "...we will dispose all of the values 1 and 2... <br><br>";
        secondDiv.innerHTML += "...and we will get: " + JSON.stringify(result) + "<br>";

</script>
</body>

</html>

Responses

0 Replies