Javascript – How to cancel `setTimeout` after Promisification
I'm using setTimeout as a Promise. But then I cannot cancel it using clearTimeout. THis is my code: const delay = (ms) => new Promise((res) => setTimeout(res, ms)); delay(1000).then(() => console.log("Done")); But using this approach I cannot cancel timeout using…