A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/lodash-_-defer-method/ below:

Lodash _.defer() Method - GeeksforGeeks

Lodash _.defer() Method

Last Updated : 03 Sep, 2024

Lodash _.defer() method in lodash is used to defer the calling of the func parameter until the recent call stack is cleared. Moreover, any further arguments are provided to the function parameter of this method when it is called.

Syntax:
_.defer(func, [args]);
Parameters: Return Value:

Example 1: In this example, we are using the lodash _.defer() method because of this 'Content' is printing first.

JavaScript
// Requiring lodash library
const _ = require('lodash');

// Calling defer() method with
// its parameter
_.defer(function (content) {
    console.log(content);
}, 'GeeksforGeeks!');

// Prints content after this
console.log('Content:');

Output:

Content:
GeeksforGeeks!

Example 2: In this example, we are using the lodash _.defer() method because of this 'Integers are as follows:' is printing first.

JavaScript
// Requiring lodash library
const _ = require('lodash');

// Defining func parameter
let func = number => {
    console.log(number);
};

// Defining for loop
for (let i = 1; i <= 5; i++) {

    // Calling defer() method
    // with its parameter
    _.defer(func, i);
}

// Prints integer after this
console.log('Integers are as follows:');

Output:

Integers are as follows:
1
2
3
4
5


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4