DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Classic scripts vs module scripts in JavaScript
Hadeel Wadia
Hadeel Wadia

Posted on

Classic scripts vs module scripts in JavaScript

IN MODULE SCRIPT

  1. The value of "this" is undefined at the outer scope (not window). 2.Modules are always executed in strict mode. 3.All objects (class, const, function, let or var) are private unless explicitly exported. 4.Modules are loaded asynchronously 5.Modules can use import and export. 6.Modules are singleton. They will be loaded and executed only once. 7.module script is one that contains an ES6 module, i.e. it uses (or: can use) import and export declarations. 8.The JavaScript specification defines a syntax for modules through using type="module" in script tag. 9.Any requests by import in the module script are a module .

IN CLASSIC SCRIPT OR NOURMAL SCRIPT

  1. The value of "this" is window object 2.classic are always executed without strict mode until using strict mode in top classic script. 3.All objects (class, const, function, let or var) are public. 4.Modules are loaded synchronously 5.classic script can't use import and export. 7.module script is one that contains an ES6 module, i.e. it uses (or: can use) import and export declarations. 8.The default type is javascript/text in classic script

Top comments (0)

Here is a post you might want to check out:

Regex for lazy developers

regex for lazy devs

Sorry for the callout πŸ˜†