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

use const to replace var #579

Closed
Freed-Wu opened this issue Jan 13, 2025 · 3 comments
Closed

use const to replace var #579

Freed-Wu opened this issue Jan 13, 2025 · 3 comments

Comments

@Freed-Wu
Copy link
Contributor

Such as https://github.com/nodejs/node-addon-examples/blob/main/src/1-getting-started/1_hello_world/nan/hello.js

A variable declared with var is accessible in the whole module. Thus, the variable can be accessed before its initialization and outside the block where it is declared.

See MDN web docs for more details.

Unsafe fix: Use 'const' instead.

@mhdawson
Copy link
Member

Happy to accept PRs to make those changes.

@mhdawson mhdawson moved this from Need Triage to Todo in Node-API Team Project Jan 24, 2025
@yermartee
Copy link
Contributor

Hi @mhdawson I've opened a PR for this. I've replaced var with const, and with let where mutability is required. Please review it and let me know if there are any further improvements I could make. Thanks in advance.

@mhdawson
Copy link
Member

Closing as PR to address has landed. @yermartee many thanks for your contribution.

@github-project-automation github-project-automation bot moved this from Todo to Done in Node-API Team Project Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants