JavaScript: export vs export default - creating modules

Published: 06 March 2023
on channel: Game Dev for Noobs
70
0

JavaScript Code can sometimes grow to huge sizes.
When everything is in one place, one file, it can be overwhelming and hard to navigate through.

To help maintain order, you can use something called a "module".

What is a Module?

A module is simply a file, a regular file, containing a smaller part of the code responsible for a specific action, such as the visual appearance and functionality of a button. Only that button and that's it.

So, each module has its function and can be imported.

What does it mean to import? It means to transfer the functionality of one module to another part of the code. It's like copying code from one place to another while maintaining readability.

Thanks to this, you can create code that is easier to understand, but also easier to develop and maintain in larger and more complex web applications.

In short, export and export default allow you to download code fragments that you have written and make them available in other parts of your program.

It's like having your own library of code that you can use whenever you need it!

Now, I know what you might be thinking: "That sounds great, but how do I actually use export and export default in my own code?" Well, it's actually pretty easy! All you have to do is use the "export" keyword to share specific code fragments with other parts of your program. And if you have a main piece of code that you want to share, you can use "export default" instead.

But here's the catch: it can sometimes be a bit difficult to know exactly when and how to use export and export default in your code. That's why I'm here to help! In this lesson, I'll break down everything you need to know about export and export default, including how to use them, best practices, and examples.

So, are you ready to become an expert in JavaScript export and export default? Let's do it!

More about JavaScript in the course:
https://www.udemy.com/course/javascri...

#js #javascript #javascript_tutorial #exportjs #importjs #exportdefault

0:00 what is a module?
1:18 creating an application in one file
3:36 separating the application into modules
4:25 import
5:31 export
6:09 type "module"
7:44 export default
8:32 mixing export default and export
10:37 export default at the end of the file
11:35 without .js
12:27 importing from lower/higher directories
14:00 exercise


On this page of the site you can watch the video online JavaScript: export vs export default - creating modules with a duration of hours minute second in good quality, which was uploaded by the user Game Dev for Noobs 06 March 2023, share the link with friends and acquaintances, this video has already been watched 70 times on youtube and it was liked by 0 viewers. Enjoy your viewing!