The import.meta object is a meta-property exposing context-specific meta data to a JavaScript Module. It contains information about the module, like the module's URL.
Syntax: import.meta
The import.meta
object consists of the keyword import, a dot, and a property name meta. Normally import serves as the context for property access, but here import is not an object.
The import.meta object is created by the ECMAScript implementation, with a null prototype. The object is extensible, and its properties are writable, configurable and enumerable.
Example:
Given a module name module.js
<script type="module" src="module.js"></script>
you can access meta information about the module using the import.meta object.
console.log(import.meta); // {url:
"file:///home/user/module.js"}
It returns an object with a URL property indicating the base URL of the module. This will; either be the URL from which the script was obtained for external scripts or the document base URL of the containing document for inline scripts.
Thank You for Reading.

Comments (0)