JSFiddle - React, Tailwind, and code Playground

by Paco86

JavaScript

function fn() {
	console.log([...arguments]);
}
 
function delay(fn) {
  return (...args) => {
  	setTimeout(()=>{
    	fn(...args);
     }, 2000);
  }
}

const withDelay = delay(fn);

withDelay('abc123', 'xxx'); // after 2 seconds, console.log('abc123')