Lodash.js – delay() function

A simple Lodash.js example of the delay() function, which invokes once the specified function after the desired time span.
<!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 milis = 3000;

    var firstValue = function() {

        secondDiv.innerHTML = "<br><br>...we will use the constant function, to create a function variable which will return a value... and we get:<br><br>";
        secondDiv.innerHTML += (String(milis) + " of miliseconds have passed and you can see it :)");

    };

        firstDiv.innerHTML = "Having a function:<br><br><br><br>";
        firstDiv.innerHTML += firstValue;

    var result = _.delay(firstValue, milis);

</script>
</body>

</html>

Responses

0 Replies