Skip to content

remove unused parameters and improve code quality #449

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ltlylfun
Copy link

@ltlylfun ltlylfun commented Jun 5, 2025

I noticed that the usage of some parameters didn't seem to follow conventions, so I modified them.

@ltlylfun
Copy link
Author

ltlylfun commented Jun 5, 2025

The original code incorrectly included a third parameter in the Promise constructor:

return new Promise((resolve, reject, link) => { ... });

However, according to the JavaScript specification, the Promise executor function must only take two parameters: resolve and reject. Any additional parameters are ignored.

I refactored the code to define variables like link and request inside the executor function using const, which is the correct and idiomatic way to declare them:

return new Promise((resolve, reject) => {
  const link = document.createElement('link');
  ...
});

This makes the code cleaner, conforms to JavaScript best practices, and prevents potential bugs or confusion.

@ltlylfun
Copy link
Author

ltlylfun commented Jun 5, 2025

In the original code:

function hasPrefetch(link) {
  link = document.createElement('link');
}

The link parameter was unused and immediately overwritten, which made it redundant and potentially misleading.
I removed the parameter and defined link as a const inside the function:

function hasPrefetch() {
  const link = document.createElement('link');
}

This makes the function cleaner, easier to read, and avoids confusion about the purpose of the parameter. It also follows best practices by minimizing the function's input to only what is necessary.

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.

1 participant