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

test function has a side effect #37245

Closed
xipeter opened this issue Dec 17, 2024 · 2 comments
Closed

test function has a side effect #37245

xipeter opened this issue Dec 17, 2024 · 2 comments
Labels
closed: question A user misinterpretation or support question. No action required. Content:JS JavaScript docs

Comments

@xipeter
Copy link

xipeter commented Dec 17, 2024

const str = "0.#%"; const RE = /%/g; console.log(RE.test(str)+ " "+RE.test(str));

For this code above, the result is different for each call, which is true, false, it should be true, true.

@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Dec 17, 2024
@Josh-Cena
Copy link
Member

This is already mentioned on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test.

@Josh-Cena Josh-Cena closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2024
@Josh-Cena Josh-Cena added closed: question A user misinterpretation or support question. No action required. Content:JS JavaScript docs and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Dec 17, 2024
@xipeter
Copy link
Author

xipeter commented Dec 17, 2024

Thanks, I didn't pay attention to this part, my bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: question A user misinterpretation or support question. No action required. Content:JS JavaScript docs
Projects
None yet
Development

No branches or pull requests

2 participants