That's the point - they behave the same, but you don't have to create new variables for the same functionality throughout your app. Instead you just use the same function once you need timer functionality for something.
Furthermore, if you need different function signature, you can use the latter assigning it to different var.
/**
* Sleep pause.
*
* @param {Number} time The time in milliseconds.
* @return {Promise<void>}
*/constsleep=(time)=>newPromise((resolve)=>{setTimeout(resolve,time)})
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That's the point - they behave the same, but you don't have to create new variables for the same functionality throughout your app. Instead you just use the same function once you need timer functionality for something.
Furthermore, if you need different function signature, you can use the latter assigning it to different var.
if I assign
setTimeout
that will force me to create new unnecesary variables in the entire app? And that doesn't happen if I wrap it in a function?