JavaScript ES6 Modules




With ES6 JavaScript changed from a programming language that many people dreaded using to one of the most popular and loved languages. Of the new changes in ES6 the addition of modules was one of, if not, the biggest change that pushed JavaScript to where it is now. Modules make it so much easier to write clean and reusable code. In this video we will discuss how to use ES6 modules and why they are so important to JavaScript.

Twitter:

GitHub:
https://github.com/WebDevSimplified

CodePen:
https://codepen.io/WebDevSimplified

#JavaScript #ES6 #Modules

Original source


27 responses to “JavaScript ES6 Modules”

  1. Good video but these imports serve the same purpose as PHP's `include` which made it very efficient for churning out spaghetti code for inexperienced users. IMO, JS is starting to get messy.

  2. Holy fucking shit… I finally understand what modules are, and not only that, now I finally understand when you're supposed to use braces in import statements and when not to… Bro, you deserve to be world-famous, seriously. This is amazing.

  3. Hello, I have a problem that's giving me trouble – so, I did everything like in the video, even added the type="module" attribute tot the script but it's not working. I'm getting 2 errors – "Access to script at 'file:///G:/Projects/catalogue/js/app.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. " and "GET file:///G:/Projects/catalogue/js/app.js net::ERR_FAILED". Some info would be appreciated.

  4. Hey, man, appreciate the content! I have a problem – when I import the User class I get an error in Mozilla that my file was blocked because of a disallowed MIME type (“text/html”) – I gave a type module in the html, not sure what's happening. Can you give me an advice how to fix this, or maybe I did something wrong? Thanks a lot!

  5. Hi there. How would you test ES6 code (like a utils.js) in something like mocha, where you can't do import and a require() complains about the export command? I'm having trouble finding good articles on it. If you read this, thanks.

  6. I have seen this on React… I say I have seen it because I have not properly learn Reach yet, I am learning modern JS currently but I have seen tutorials where import and export is being use with the same functionality shown in the video… are Modules similar to what they do in React?

  7. Hi, anybody know how to solve this, CORS POLICY?

    Error: Access to Script at 'file:///C:*******/es6/code.js' from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access.

Leave a Reply