JavaScript · Senior · Question 69 of 75

What is new URL("./worker.js", import.meta.url) used for?

Explanation

Relative URLs in fetch or new Worker resolve against the page, not the module. import.meta.url gives the module's own URL.

Further reading

Problem with a question

JavaScript · Senior · question 69

Test yourself

Take the JavaScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz