You might also get a question regarding modular system, and they mean by this ActionScript six modules
are common just modules.
And for example, the question can be create and it must grip six module with functions.
Get name, surname and default expert, get full name.
And for this, you must know how modules are work in JavaScript just because it is the core component
of JavaScript and we're using modules everywhere.
And to use the inputs, we must create one more file, as you can see here, I have Manges.
This is our main file and index each HTML.
So let's say that we are creating a new module and we want to name it, for example, ActionScript six
dot and instead we will write some ActionScript six module.
So first of all, here we want to create a method to get name and variety in it with expert Konst.
Here is get name.
And here we are, getting as an argument name and were written in back our name.
And as you can see here, we use the construction expert Konst.
And this is exactly one of the functions that we must create.
And as you can see, you get the name and gets her name.
I just named functions.
This is why we were writing them and we're experts in them from this module was expert Konst.
So I will copy this line and paste here, and we must name it.
Get surname here by getting our surname and we are just returning our surname.
And the last thing that we must create is default expert, forgetful name.
And if you don't know how to create default expert, this is expert default.
And here we don't need to provide a name, which means here we directly have a function.
In our case, maybe we can create it like this name and surname, and we're just going to coordinate
it inside.
So here we have a Nechama script 16, and we just call here to our functions.
First of all, get name and we're passing inside name.
After this, we have a space in here.
We have a second function, gets our name, web biosensor name inside.
Now our ActionScript 6GHz file is a module and it is completely isolated and only what we export it
here is available outside.
So let's use it now.
We have here three functions must jump in our main chairs and here we must empower them and were inputting
them like this input.
Then we have brackets and inside what we're importing, it is get name korma, gets her name.
And as you can see, my wife's editor already rolled from and here ActionScript six.
And as you can see, it is, of course, black because we are not using this functions.
This is why here I want to write, get name and where possible.
And so for example, Jack, then we have here get surname and here will be special.
And this is how we're importing and using name exports.
So we're using here word import.
Then brackets and inside named functions.
In our case, get name gets a name from.
And this is the path to our file ActionScript six digest.
Now the question is how we can get our default export.
And for this, we can write just directly after input, get full name and then comma.
In this case, we will get our default export first and then named experts just with brackets afterwards.
Now here, inside our console.log, we can use get full name and we're passing inside two strings.
First of all, Jack and secondly Spiro.
And now we can use this functions just like they were defined in this particular file.
Now the question is how we can use ActionScript six module inside our HDMI out, and for this, we must
jump inside our HTML.
And here we have script with source manges.
This is totally fine, but we must write here type module and then it will be imported like ActionScript
six module.
Now let's try to reload our page, as you can see.
Actually, it worked, but we're getting an error and we're getting coarse error because this index
such HTML can't really loud manges because you can't make a cross origin request from file.
And this is actually a problem, because here I am using this source file just like normal indexes for
HTML file.
And if you are using some frontend framework like rectangular, you won't have such problem because
you have modular systems.
They're out of the box.
But exactly for this specific case where I have plain indexes, your HTML, I must serve this index
HTML like a web server.
And for this there is a package which is called serve.
You can install.
It was known chess and as you can see now, it is available for me, just this index, which HTML on
localhost three thousand.
Now, as you can see, we don't have an error regarding cause, but we have a problem to load our ActionScript
six file because actually, here we must put dodger's to load this file.
Now we're not getting this error, and as you can see in console this, all functions are available
fast.
So here we can see Jack Sparrow and Jack Sparrow.
And this means that we successfully imported these three functions was named expert and default expert
from our module by using ActionScript six modules.
Now we have a next question which must create exactly the same stuff with common just module.
And if you don't know, common just model is typically used inside notice.
This is why now I want to write our ActionScript six, just file with using of common chess.
This is why I will copy, paste everything and create here in your file.
Just name it Common Dog Chess, and we will write everything here in common just module.
You can do the same.
You can't have simultaneously a default expert and name experts.
And this is because instead of expert const, we're right in here.
Module dot experts dot get name and best sign in a function here.
The main point is if we want to write a default expert, we're writing instead of expert default module
dot experts equals.
And here is our function, which means here we have a default input for our function.
So what we can do in this case is just leave this cat name and get surname as private functions because
we can't really explode them simultaneously with our default expert.
And as you can see here, we have module experts just to have our default expert.
Now we can jump directly in, yes and here import our default function.
But to do this, we must use the required keyword.
This is why here I want to write concert and we're getting the get full name and here equals require.
And here is our path common, Jess or just common?
Now I can jump inside console and write node manges.
And obviously we're getting the message get name is not.
Define it because here we are trying to console.log, get name and get surname.
Now here I have just get full name.
Let's try again.
As you can see, we don't have any errors and we're getting checks better.
If we really want to get all three functions, we must jump here and just use everywhere.
Module dot experts dot and here will be our guest name.
Now here will be a module dot experts.
Dot gets their name and here we want module dot experts and here will be get full name.
In this case, it will work and we will get our three functions.
Now we have three experts.
We can come back in Manchester and here instead of get full name, we can just do structure and get
three functions get name, get surname and here get full.
Name and number can uncommon this to consulates.
Let's check this out and jump into console and run node mangers, and we still get in there to get name
is not define it.
But actually the problem here is that in so common, yes, we don't have a function, get name and get
surname because actually we have them only in module experts.
This is why this code won't work.
We really need to, right, first of all, get name.
And then after this module, experts don't get name and here equals get name.
In this case, this function can also work, and we must do exactly the same for our get surname.
So here will be const gets name and let's move it to the top.
And now here is our experts get name.
And now here we can get their name and birth.
Sign in here our function get surname.
In this case, all functions are available for us inside this file and also outside through module experts.
Let's check this out.
I am running Node Manges and we don't have any errors.
So as you can see, we have two different variants ActionScript six and Common Chest.
And if you coded all this questions, then the next question might be what is the difference between
ActionScript six modules and common just modules?
And actually, as they already said, common just modules are typically used inside node chess.
This is the standard modular system for node chess ActionScript six modules we have in-browser.
This is ActionScript six JavaScript, and actually you can use ActionScript six modules inside Node.js.
This is just the sugar around requir.
This is why if you assign ActionScript six modules inside node, just you know that inside you still
have requir because it is mandatory for node chess and ActionScript.
Six modules are, first of all, newer than common just modules.
And secondly, they are static, which actually means you can peg this require inside if condition,
for example, or inside for loop, but you can't really do it with input because input must be always
on the top.
And if input is not on the top, then it will bubble automatically to the top.
When the JavaScript passes it, and this is actually much better, first of all, for safety and secondly,
to implement different building tools on the top of ActionScript six modules.