Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

throttling function in javascript

function throttle(someFn, delay) {
  let flag = true;
  return (() => {
    if(flag){
      someFn();
      flag=false;
    }
    setTimeout(() => {flag=true;}, delay);
  })();
  
};

// usage
function someFn() {
  console.log('Hi')
};

throttle(someFn, 1000);
Comment

PREVIOUS NEXT
Code Example
Javascript :: check if message mentions users discord js 
Javascript :: extract words from string js 
Javascript :: get dirname to last directory node 
Javascript :: mongodb import from json 
Javascript :: vue on click router push not working 
Javascript :: get url params with js 
Javascript :: startswith 
Javascript :: get ip address js 
Javascript :: how get value of json encode in laravel 
Javascript :: javascript get dictionary values 
Javascript :: javascript class 
Javascript :: JAVASCRIPT KEYDOWN AROW 
Javascript :: vue dynamic component props 
Javascript :: get screen resolution jquery 
Javascript :: promise recursive settimeout 
Javascript :: javascript check if number is hexadecimal 
Javascript :: fetch api cors 
Javascript :: javascript sum of array 
Javascript :: how to convert milliseconds to time in javascript 
Javascript :: how to go to next line in javascript 
Javascript :: jquey body onload 
Javascript :: js sort numbers descending order 
Javascript :: datatable get all selected row data 
Javascript :: how to edit website in browser using javascript on google chrome 
Javascript :: how to check if window is loaded javascript 
Javascript :: disable eslint specific rule 
Javascript :: how to convert string to lowercase in javascript 
Javascript :: shuffle an array of numbers in javascript 
Javascript :: send data from one page to another html page in Javascript 
Javascript :: invert binary tree javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =