FrontendDeveloper.in

JavaScript question detail

How do you get the metadata of a module

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.

<script type="module" src="welcome-module.js"></script>;
console.log(import.meta); // { url: "file:///home/user/welcome-module.js" }
Back to all JavaScript questions
Get LinkedIn Premium at Rs 399