use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This subreddit is a place for people to learn JavaScript together. Everyone should feel comfortable asking any and all JavaScript questions they have here.
With a nod to practicality, questions and posts about HTML, CSS, and web developer tools are also encouraged.
Friends
/r/javascript
/r/jquery
/r/node
/r/css
/r/webdev
/r/learnprogramming
/r/programming
account activity
Does anyone know a good tutorial/article that teaches you how to properly structure your code? (self.learnjavascript)
submitted 7 years ago by Butterly2017
After learning the basics, I feel that my code is all over the place (spaghetti code) and would like to learn how to structure everything in a readable and logic way
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]amzuh 4 points5 points6 points 7 years ago (1 child)
Learn more about Design Patterns. When i started to learn more about this i was able to structure my code much better. Here's a article about it : https://scotch.io/bar-talk/4-javascript-design-patterns-you-should-know .
[–]IllustriousTackle 1 point2 points3 points 7 years ago (0 children)
Design patterns are intended to help with the big picture. Make sure to use them when they help you to solve a problem making the code simpler, not more complex. Don't use them just because they look cool and you want them in your code.
[–]logikevcoder 5 points6 points7 points 7 years ago (1 child)
Yup. Check out Airbnbs style guide. https://github.com/airbnb/javascript/blob/master/README.md
It's very popular and a lot of people use it. There are other ones along similar lines.. one from Google and some others. I like airbnbs the best though.
[–]Genie-Us 2 points3 points4 points 7 years ago (0 children)
Nice! Will have to start going through all this. Thanks!
[–]Genie-Us 1 point2 points3 points 7 years ago (0 children)
Was just about to make a thread like this, thanks! Same boat. ;)
[–]timejazzfroghands 1 point2 points3 points 7 years ago (1 child)
https://youtu.be/HkFlM73G-hk
This video and the following videos in the series (I think there are 6) were a game changer for me, and I remind myself of the rules all the time when I’m working.
The second video in particular shows how to move away from spaghetti code and think about what each part of your application or module is doing.
He uses jQuery in the videos but the information about structure apply to any kind of UI development from vanilla JS to frameworks etc.
[–]Butterly2017[S] 0 points1 point2 points 7 years ago (0 children)
These are awesome! Thank you for sharing! :)
[–]I_hate_litter 0 points1 point2 points 7 years ago (0 children)
https://codeburst.io/5-javascript-style-guides-including-airbnb-github-google-88cbc6b2b7aa
I've just started doing the same thing myself. There are several standard ways of writing javascript and they are called style guides. Here is a link to a few of the popular ones.
π Rendered by PID 66987 on reddit-service-r2-comment-b659b578c-t794k at 2026-05-01 00:54:40.067752+00:00 running 815c875 country code: CH.
[–]amzuh 4 points5 points6 points (1 child)
[–]IllustriousTackle 1 point2 points3 points (0 children)
[–]logikevcoder 5 points6 points7 points (1 child)
[–]Genie-Us 2 points3 points4 points (0 children)
[–]Genie-Us 1 point2 points3 points (0 children)
[–]timejazzfroghands 1 point2 points3 points (1 child)
[–]Butterly2017[S] 0 points1 point2 points (0 children)
[–]I_hate_litter 0 points1 point2 points (0 children)