Import VS require ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Import VS require ?

Can someone please explain to me what's the major difference between import and require

13th Apr 2020, 5:50 AM
ezall
ezall - avatar
3 Answers
+ 2
Dynamic import is ES2020 feature with import() operator, it is asynchronous and it returns a promise. You can import in the code blocks instead of globally, and use .then .catch .final or async await to handle the resolve and reject of the promise.
13th Apr 2020, 7:14 AM
Gordon
Gordon - avatar
+ 1
Thank you soo much for this article it really helped but i have a follow up questions what's a dynamic import what's tree shaking
13th Apr 2020, 6:08 AM
ezall
ezall - avatar
0
Thank you so much
13th Apr 2020, 5:02 PM
ezall
ezall - avatar