JavaScript · Senior · Question 69 of 75
What is new URL("./worker.js", import.meta.url) used for?
- ✓Correct answer: Resolving a file path relative to the current module, which bundlers also understand
- 2Fetching the current page URL
- 3Importing the file synchronously
Explanation
Relative URLs in fetch or new Worker resolve against the page, not the module. import.meta.url gives the module's own URL.