Is "Learn JavaScript: Modules" part of pure JS?


I’m having a hard time understanding what is part of what with the amount of frameworks and things that exist for Javascript.

I was just learning Node.js the other day and it does have export/import and require(). Yesterday I came across these terms in this Javascript course and I was thinking if they actually existed in pure javascript.

Say I have a file named a.js and a file named b.js. If on a.js I have var number = 5; I can simply do console.log(number) in b.js, if I’m using it on a web browser, with the scripts included in HTML.

And when I type export I get an error saying it doesn’t exist. So why is it taught in a Javascript course and there’s no mention about it not being default? Or am I wrong in thinking this?


Did you import in b.js?

Export and import is default:

But its important to understand a little bit of history about JS:

and how nodeJS was born


If I open a main.html file with

<script src="a.js"></script>
<script src="b.js"></script>

And have

export let a = 5;

I get Uncaught SyntaxError: Unexpected token export on google chrome’s console.

Still with that configuration, if I define a var in a.js and log it in b.js it works.


export is available for modules, as such, you have to tell the html file that a.js is a module, see here:


Thank you! That makes sense.