Skip to content

Questions on setTimeout and "current code" #1282

@paroche

Description

@paroche

There are a few things that I think could be clarified:

  1. In the body of the article and the summary, when it is stated that setTimeout executes "only after the current code is complete", it is always in the context of "zero delay" setTimeout. But then in to task 2 it is stated that it applies to "any setTimeout" (the example is for 100ms), and it looks to me like that delay is a requirement for both that task, and for the nested solution to task 1.

  2. What exactly constitutes the "current code"? The next line, or the rest of the block in which the setTimeout call appears, or ... ? All the examples were for just one line of code (though in one case it's a for loop block). I could do tests, but I thought others might wonder also.

  3. Does this also apply to setInterval? I know I could test this too, but might be good to mention it, one way or the other, in the article.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions