JS Coding Questions Logo
JS Coding Questions
#249💼 Interview💻 Code

How do you get the metadata of a module

Advertisement

728x90

You can use the import.meta object which is a meta-property exposing context-specific meta data to a JavaScript module. It contains information about the current module, such as the module's URL. In browsers, you might get different meta data than NodeJS.

javascript
1<script type="module" src="welcome-module.js"></script>;
2
3console.log(import.meta); // { url: "file:///home/user/welcome-module.js" }

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 78

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
249of476