Lodash.js – noop() function

A simple Lodash.js example of the noop() function, which returns undefined regardless of the received parameters.
<!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');

    function multiply(n) {

      firstValue *= 2;

    }

    var firstValue = 1534534;
        firstDiv.innerHTML = "Having an integer:<br><br>";
        firstDiv.innerHTML += firstValue;

        secondDiv.innerHTML = "...we will use the noop function, provide it the value of 1534534 and still get undefined... and we get:<br><br>";

    var result = _.noop(firstValue);

        secondDiv.innerHTML += result;

</script>
</body>

</html>

Responses

0 Replies