Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update setTimeout() and setInterval() Return Value Description with Numeric Range and Clarification #39006

Merged
merged 6 commits into from
Apr 8, 2025

Conversation

low-perry
Copy link
Contributor

@low-perry low-perry commented Apr 6, 2025

Description

This pull request updates the description of the return value for setTimeout() and seInterval() to clarify exactly what the returned timeout/interval identifier is—as well as to include its typical numeric range.

  • Numeric Range: Added a parenthesized note to indicate the typical numeric range of the timeout ID/ interval ID, providing developers with an expectation of its value.

  • Clarification of the Timeout/ Interval Identifier: Defined the terms "timeoutId"/"intervalId" clearly as the unique identifier returned by setTimeout()/setInterval().

  • ID Pool Clarification: Revised the language regarding the reuse of IDs by replacing “different objects” with “distinct global environments” and clarifying that each global environment (e.g., windows, iframes, workers) maintains its own separate pool of timer IDs.

Motivation

Including the numeric range information improves clarity on what developers can expect in terms of the possible values.
Explicitly defining the timeout identifier and clarifying the ID pool explanation helps prevent confusion about when and where these identifiers might be reused.

Additional details

Related issues and pull requests

Fixes #39004

@low-perry low-perry requested a review from a team as a code owner April 6, 2025 18:49
@low-perry low-perry requested review from sideshowbarker and removed request for a team April 6, 2025 18:49
@github-actions github-actions bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Apr 6, 2025
Copy link
Contributor

github-actions bot commented Apr 6, 2025

@low-perry
Copy link
Contributor Author

I think similar changes can also be included on the setInterval() method.

@low-perry low-perry changed the title Settimeout description Update setTimeout() Return Value Description with Numeric Range and Clarification Apr 6, 2025
@Josh-Cena
Copy link
Member

I think similar changes can also be included on the setInterval() method.

Feel free to

@low-perry
Copy link
Contributor Author

Feel free to

I revised the overview paragraph for the setInterval() method, removing the return value to ensure consistency with the setTimeout() overview section. Additionally, I updated the return value description for setInterval() in both the Window interface and WorkerGlobalScope interface for clarity and alignment.

@low-perry low-perry changed the title Update setTimeout() Return Value Description with Numeric Range and Clarification Update setTimeout() and setInterval() Return Value Description with Numeric Range and Clarification Apr 7, 2025
@sideshowbarker sideshowbarker merged commit 29d6bb9 into mdn:main Apr 8, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify "timeoutID" terminology and "separate pools of IDs" wording in setTimeout() Return Value Description
3 participants