function nextTick(callback) { Promise.resolve().then(callback); } // Usage nextTick(() => { console.log('This runs after the current tick.'); }); console.log('This runs first.');