Lodash _.delay Method Example

The _.delay() function delays the execution of a function for the specified amount of milliseconds.

Learn Lodash JS at Lodash JS Tutorial with Examples.

Lodash _.delay Method Example

<!DOCTYPE html>
<html>
<head>
    <title>Lodash Tutorial</title>
    <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>

    <script type="text/javascript">
  function message()
  {
   console.log("Some message");
  }
  _.delay(message, 150);
  console.log("Some other message");
    </script>
</head>
<body></body>
</html>
The example outputs two messages. The first one is delayed for 150ms. Here is the output:
Some other message
Some message

Reference


Comments