I was a looking for a valid way to check if timeout still exists in order to clear it before. But realised it's number
all the time at least in latest Chrome
and Safari
. I will appreciate a lot if somebody could shine some line on this case:
const timeout = setTimeout(() => {
// do magic
}, 100000)
console.log(typeof timeout) // number (makes sense)
clearTimeout(timeout)
console.log(typeof timeout) // number (...hmm)
setTimeout(() => {
console.log(typeof timeout) // number --> magic ¯\_(ツ)_/¯
}, 1000)