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

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

use const to replace var #579

Freed-Wu opened this issue Jan 13, 2025 · 2 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.

@yermartee
Copy link

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.

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

No branches or pull requests

3 participants