How to add a timeout without set timeout function for a delay?

Sometimes the function we have written in the code will run before the page load. In such cases we can use a delay.

The _.defer() function is used to invoke/call a function until the current call stack is cleared. Its major advantage is that it performs expensive computations, calculations or HTML in chunks without blocking the UI threads from updating. It has similar functioning to setTimeOut() function with a delay of 0. The function which is passed to this function will be invoked first. 

syntax:

_.defer(function, *arguments)

Parameters: 
It takes two arguments:

  • The function
  • The arguments (optional)

Leave a comment

Your email address will not be published. Required fields are marked *