Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript sleep settimeout

setTimeout(() => {  console.log("World!"); }, 2000);
Comment

how to pause settimeout in javascript

var Timer = function(callback, delay) {
    var timerId, start, remaining = delay;

    this.pause = function() {
        window.clearTimeout(timerId);
        timerId = null;
        remaining -= Date.now() - start;
    };

    this.resume = function() {
        if (timerId) {
            return;
        }

        start = Date.now();
        timerId = window.setTimeout(callback, remaining);
    };

    this.resume();
};

var timer = new Timer(function() {
    alert("Done!");
}, 1000);

timer.pause();
// Do some stuff...
timer.resume();
Comment

PREVIOUS NEXT
Code Example
Javascript :: electron open new window 
Javascript :: check all values from keys in object js 
Javascript :: javascript on script loaded 
Javascript :: req body express 
Javascript :: js remove item from array by value 
Javascript :: js add more text to element 
Javascript :: disable button click jquery 
Javascript :: javascript change input value 
Javascript :: dom element get attribute 
Javascript :: convert response to json javascript 
Javascript :: Codewars JS Multiples of 3 or 5 
Javascript :: javascript syntax for check null or undefined or empty 
Javascript :: js read from json2 
Javascript :: how to create a global variable in vue 
Javascript :: javascript find all odd between two numbers 
Javascript :: angular disabled condition based 
Javascript :: typeahead cdn 
Javascript :: luxon timestamp 
Javascript :: split date 
Javascript :: js is array 
Javascript :: event.target data-target 
Javascript :: async setstate useeffect 
Javascript :: how to remove duplicate values in array of objects using javascript 
Javascript :: vanilla javascript add class 
Javascript :: Auto scroll to bottom of div angular 
Javascript :: enter only numbers in input field angular 
Javascript :: javascript pass object by value 
Javascript :: alphabet only in jquery 
Javascript :: node read file sync 
Javascript :: dropzone get response 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =