Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

Lodash _.delay() Method

  • Last Updated : 23 Sep, 2020

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.

The _.delay() method is used to call the given function as the parameter after the stated wait time is over, which is in milliseconds. Any further arguments are provided to the function when it is called.

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!


_.delay( func, wait, args )

Parameters: This method accepts three parameters as mentioned above and described below:

  • func: It is the function that has to be delayed.
  • wait: It is the number of milliseconds for which the function call is delayed.
  • args: It is the arguments with which the given function is being called. It is an optional parameter.

Return Value: This method returns the timer id.

Example 1: In this example, the content is printed after the delay of 3 seconds as the wait time is 3 seconds.


// Requiring lodash library
const _ = require('lodash');
// Using the _.delay() method
// with its parameter
_.delay(function(content) {
  }, 3000, 'GeeksforGeeks!');
// Print the content after this line



Example 2: In this example, each integer is printed after a delay of 2 seconds.


// Requiring lodash library
const _ = require('lodash');
// Defining func parameter
let func = number => {
// Defining for loop
for(let i = 1; i <= 5; i++) {
    // Using the _.delay() method
    // with its parameter
    _.delay(func, 2000 * (i + 1), i);
// Prints the integer after this line
console.log('Integers are as follows:');


Integers are as follows:

My Personal Notes arrow_drop_up
Recommended Articles
Page :