Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the differences between ES Module and CommonJs in js

Shulou Source: shulou.com Published: 2022-06-03 06:43:47 09月10日 Update

This article mainly talks about "what are the differences between ES Module and CommonJs in js". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what are the differences between ES Module and CommonJs in js?"

1. The process of loading js files in CommonJS module is synchronous and loaded at run time.

2. ES Module loads the js file when compiling (parsing), and it is asynchronous.

3. ES Module derives a reference to the variable itself through export.

Example

Let name = 'coderwhy'; setTimeout () = > {name = "Lakers Champion";}, 1000); setTimeout (() = > {console.log (name);}, 2000); export {name} so far, I believe you have a deeper understanding of "what's the difference between ES Module and CommonJs in js". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Content documents fashion process learning practical deeper interest champion variable example practicality practical easy to operate method is in more friends module website 报价宝 降噪耳机价格 耳机价格 红米手机价格 华为手机价格 小米手机价格 电视机价格 笔记本电脑价格 笔记本价格 汽车价格 NVidia MariaDB Shulou Tech Info Shulou Technology MySQL