Answers for "settimeout for function that takes an argument"

0

setTimeout without arguments

/*
setTimeout removes the function from the execution queue and it will only be invoked after JavaScript has finished with the current execution queue. 
*/

console.log(1);
setTimeout(function() {console.log(2)});
console.log(3);
console.log(4);
console.log(5);
//console logs 1,3,4,5,2
Posted by: Guest on July-08-2021
0

the settimeout() method receives the second parameter in

/*
	The setTimeout() function takes two arguments. One for the function to call and one for
	the time delay in milliseconds.
*/
//Example for alerting a user after 1 hour.

function timeUp(){
	alert("You have crossed your screen time limit.");
  	location.reload();
}

setTimeout(timeUp, 3.6 * Math.pow(10, 6)); //1 hour = 3.6 * 10^6 milliseconds.
Posted by: Guest on March-04-2022

Code answers related to "settimeout for function that takes an argument"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language