Skip to content

Commit 32120fb

Browse files
committed
import.meta
1 parent 77655a2 commit 32120fb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

1-js/10-modules/01-modules-intro/article.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,21 @@ alert(admin.name); // *!*Pete*/!*
305305
sayHi(); // Ready to serve, *!*Pete*/!*!
306306
```
307307
308+
### import.meta
309+
310+
The object `import.meta` contains the information about the current module.
311+
312+
Its content depends on the environment, in a browser it contains the url of the script, or a webpage if inside HTML
313+
314+
```
315+
alert(import.meta.url); // the url of the current page (or the script URL)
316+
```
317+
308318
### Top-level "this" is undefined
309319
310-
In a module, top-level `this` is undefined (as opposed to a global object in non-module scripts):
320+
That's kind of a minor feature, but for completeness we should mention it.
321+
322+
In a module, top-level `this` is undefined, as opposed to a global object in non-module scripts:
311323
312324
```html run height=0
313325
<script>

0 commit comments

Comments
 (0)