Skip to content

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.

@XhmikosR XhmikosR added the squash Squash PR label Jun 14, 2025
@XhmikosR XhmikosR mentioned this pull request Jun 14, 2025
@ltlylfun ltlylfun closed this by deleting the head repository Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

squash Squash PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants