Skip to content

[Done]Update the array#forEach implement #408

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

Merged
merged 1 commit into from
Jan 9, 2019

Conversation

LiaoPeng
Copy link
Contributor

@LiaoPeng LiaoPeng commented Jan 9, 2019

The AS code

Print index: 0. value: 0
Print index: 1. value: 1
Print index: 2. value: 100
Print index: 3. value: 101
Print index: 4. value: 102
The array content:
Print index: 0. value: 0
Print index: 1. value: 1
Print index: 2. value: 333
Print index: 3. value: 334
Print index: 4. value: 335
Print index: 5. value: 336
Print index: 6. value: 337
Print index: 7. value: 338
Print index: 8. value: 339
Print index: 9. value: 340

The forEach visited elements:
Print index: 2. value: 100
Print index: 3. value: 101
The array elements in fact:
Print index: 2. value: 333
Print index: 3. value: 334

When callbackfn of forEach called push method, it maybe reallocate the memory.
It maybe lead the forEach method referring overdue data.

Signed-off-by: Liao.Peng <pengliao@live.cn>
@dcodeIO dcodeIO merged commit 9ec226d into AssemblyScript:master Jan 9, 2019
@dcodeIO
Copy link
Member

dcodeIO commented Jan 9, 2019

Thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants