I am having a strange situation where a variable is assigned (and I made sure the assigned value is not undefined
) but the value is always undefined
. Strangely enough when inspecting the value by hovering it in DevTools, it shows the correct value but the evaluated expression in the console is still undefined
and the code acts as if it’s undefined:
Here are all the code that involves this.#lastDownload
:
customElements.define("popup-page", class extends HTMLElement {
// ...
#lastDownload = 0;
// ...
async #download() {
// ...
this.#lastDownload = 0;
// ...
for (let i = 0; i < urls.length; i++) {
// ...
const id = el.downloadId = await this.#attemptItemAsync(url, maxCon, addDelay);
}
}
async #attemptItemAsync(url, maxCon, addDelay) {
try {
if (addDelay > 0) {
const now = Date.now();
if (now - this.#lastDownload < addDelay) {
await sleepAsync(now - this.#lastDownload);
}
this.#lastDownload = now;
}
// ...
}
catch {
return;
}
}
});
As you can see, there is no way #lastDownload
get assigned undefined. However after even running line 90 (now
is a number and I checked and the value is a correct number), it is still undefined
.
What am I missing?