¿Qué hay de malo en este claro tiempo de espera?

It's not working for some reason (in coffeescript)

afunction = () ->

    timeoutID = window.setTimeout (-> 
    ), 4000

preguntado el 28 de agosto de 11 a las 01:08

1 Respuestas

timeoutID is a local variable, so each time you call the method, timeoutID starts off undefined.

Respondido 28 ago 11, 06:08

This is one of those "good" traps for young players. Imagine there's no global variables - it's easy if you try ;-) - PandaWood

So the quick fix is to either put timeoutID = null fuera de aFunction (thus moving the variable to a higher scope), or changing timeoutID = ... a window.timeoutID = ... (making it a global). - Trevor Burnham

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.