+ 1

js

const removeToast = (toast) => { toast.classList.add("hide"); if(toast.timeoutId) clearTimeout(toast.timeoutId); toast.remove(),500); } I want to ask what is the function of (timeoutId) I'm so confused

14th Jan 2023, 3:34 PM
Danang Setio Arifin
Danang Setio Arifin - avatar
1 Odpowiedź
+ 2
Looking at the call to clearTimeout(), looks like `toast.timeoutId` represents a timeout ID that was created using setTimeout() https://developer.mozilla.org/en-US/docs/Web/API/setTimeout But can't say for sure about anything without looking at the toast object or its class - if it wasn't a literal.
14th Jan 2023, 3:51 PM
Ipang