JavaScript Modules In 90 Seconds #JavaScriptJanuary

preview_player
Показать описание
Watch the entire #JavaScriptJanuary series from the beginning!

Modules allow you to break up your code into separate files. This helps to organize and keep your code clean.

A module can export code in several ways, and this will affect the way the consumer imports it.

One way to export something is by setting a default. So we can add “export default” to the beginning of the item we are exporting.

We also have a consumer which is the main JavaScript file that is defined in the HTML file. Here we can import the function like this. Note that this requires either a relative or absolute URL, so use either ./ or / before the file name, whichever is applicable.

Now we can use the function in our consumer.

When importing a default export, you can name the import whatever you want.

Note that you can only have one default export per module and a default export is not required.

We can export more that one thing from a module. We just need to add export before it.

Now in our consumer we can import those as well. Note that the default export does not require curly braces but the others do.

We can also rename these in our consumer by using an alias.

So what is the benefit of using modules? Modules are tree shakable (import what you need, shake off the rest) The consumer can import only what they need, which results in smaller bundles and better performance.

ES Modules was introduced in 2015, however as with any newer technology, it is important to check compatibility. As of the date of this video, browser compatibility for JavaScript modules is at 88%.

So if you need to support older browsers you will want to use something like babel to compile your code.

I'll be releasing a new video every day in January! Stay tuned..
_____________________________________

📚 Learn to CODE in just a FEW months here:
_____________________________________

🛠️ Tools I use:

_____________________________________

💖 Show support!
_____________________________________

Watch Next:
_____________________________________

Connect With Me:
_____________________________________

** Affiliate Disclaimer: Some of the above links may be affiliate links, which may generate me a sales commission at no additional cost to you.

#JavaScriptJanuary #31Days31Videos #codeSTACKr
Рекомендации по теме
Комментарии
Автор

Thanks for all of the support! Stay tuned for a new video every day in January!!

Watch the entire #JavaScriptJanuary series from the beginning!

📚 My Favorite Web Design Books 📚
Web Design with HTML, CSS, JavaScript and jQuery Set by Jon Duckett (paid link)

codeSTACKr
Автор

This is called no time wasting video. Straight to the point with no spending hours on it.

yousufkhan
Автор

That was absolute perfect! Thank you for this!

edwardangelesmedina
Автор

Very very usefull and clear explanation!
Thank you for this video!

dimitrisandroid
Автор

Simply fantastic playlist! Awesome idea! Thank you for your amazing job! I love watching all the videos you create. Understandable, precise, laconic and to the point! And very, very helpful 🙏🤗

tianaspark
Автор

Let me tell u this i really liked these series and i will share ur videos coz this channel need to be known more ur giving some awesome and short information that helps something like on the go. Really awesome keep going bro

Hotatoes
Автор

I would love to see a series like this on Python...

I wish i could have a bit of interest in JS... It's extremely useful for Js 1's

lyricsmint
Автор

Mudules sound cool. I'm gonna look for how it's used with babbel.

tisurmaster
Автор

Please make these kinda playlist for python react nextjs and aws🙏🏻
really liked all videos in this playlist short crisp and quick revision keep it up

mithson
Автор

hey man thats greet, i need to ask how you edit this fast videos which software you use
thanks in advance

elweb
Автор

#JavaScriptFebruary pls Javascript2020 :D

dyunior