Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript The Module Pattern in JavaScript

Not too sure what i just watched lol? help!!! new Js Developer!!!!!

so i've been going through the full stack js track... Somethings make sense ... others dont... but this video really though me for a loop... as a new Js developer.. what are the key things i need to take from this video.. I plan on watching it 3 or 4 more times.. but any advice would be greatly appreciated

4 Answers

Brandon Spangler
Brandon Spangler
8,756 Points

I think this video might need to be updated. I think this is the old way to create modules. I think there are a few things you need to understand. I think the big point was that modules have their own scope. Did you notice how variables created in the module were not accessible outside of the module (without using the modules interface)? Additionally, you can use modules to solve problems that it would take you a long time to solve. For example, if you wanted to find the shortest path to a particular place on a graph, you could spend time developing your own method, or you could import a module that contains a function that'll do that for you. This video was kinda a very brief overview of modules. If you're interested, I'd look up some other resources.

I'll definitely do that. I was completely lost. Any recommendations for other resources?

Brandon Spangler
Brandon Spangler
8,756 Points

Yeah, Eloquent JavaScript! It's a fantastic book. The module chapter is https://eloquentjavascript.net/10_modules.html

Thanks for those below who shared resources. Helped a lot.

Same, this teacher doesn't know how to share his info, I had the same problem with his 'This' course, I had to re watched a few times, but it wasn't till the OOJS that I really understand the 'This'

If you can, just check other sources for this course

Honestly, this professor doesn't seems to be as good as the other professors, the examples are too abstract and I don't have a clue how I can apply this in real life. Of all the topics covered in the Javascript Fullstack this is, by far, the most nonsense, adding the professor that is not good at all it makes all this very difficult to learn, understand and apply in real life since all they show are abstract examples that I don't have any idea how can I apply that in a real life project... I would be great to make a workshow of a portfolio applying this concepts. I have similar situation with many other concepts that I understand in their context at Treehouse but I don't see how to use them in real life project :(

Dennis C
Dennis C
5,010 Points

Yeah, I know the feeling.. Here is how it should've been explained from the very beginning: https://www.youtube.com/watch?v=yF3GR-7u4y4 Then continued on to: http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html

Good luck.

remedies
remedies
3,616 Points

Dennis's resources are really good especially the youtube video. Explains this topic better than others. I have some background with other programming languages and I like how it referenced how other languages worked and how javascript implements the same idea.

totally agree with you guys. this video is nonsense for beginner developers. not sure what it does in the fullstack track early on.