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

docs: update message about this when using regular function #7

Merged
merged 2 commits into from
Jul 20, 2024

Conversation

iamandrewluca
Copy link
Contributor

@iamandrewluca iamandrewluca commented Jul 16, 2024

An arrow function cannot change the this context.

In the example before, this was always the global object (global in node, window in browser)

Copy link

changeset-bot bot commented Jul 16, 2024

⚠️ No Changeset found

Latest commit: a2f1863

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@PuruVJ
Copy link
Owner

PuruVJ commented Jul 17, 2024

Thanks Andrew for the PR!

You don't this in the case above, instead you use ctx as provided as the first argument

@iamandrewluca
Copy link
Contributor Author

I thought the comment was misleading with an arrow function 🤔
In any case, if that was the purpose please close the PR 😄

// `this` is `ctx` in modern build

@PuruVJ
Copy link
Owner

PuruVJ commented Jul 17, 2024

Actually yeah, it is kind of confusing. Could you tweak the text to mean "ctx instead of this) or similar? Happy to merge that!

Copy link

pkg-pr-new bot commented Jul 17, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

commit: 0e7a309

neotraverse

npm i https://pkg.pr.new/PuruVJ/neotraverse@7


templates

@iamandrewluca
Copy link
Contributor Author

@PuruVJ made some changes

@iamandrewluca iamandrewluca changed the title docs: replace arrow with classical function because of this docs: update message about this when using regular function Jul 19, 2024
@PuruVJ PuruVJ merged commit 105c1ad into PuruVJ:main Jul 20, 2024
@PuruVJ
Copy link
Owner

PuruVJ commented Jul 20, 2024

Thanks!

@iamandrewluca iamandrewluca deleted the patch-1 branch July 20, 2024 13:43
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