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 JavaScript Foundations Arrays Methods: Part 1

Gina Bégin
PLUS
Gina Bégin
Courses Plus Student 8,613 Points

Quite a bit into the "Javascript" section of the "Front End Web Development" track & wondering: when will I use this?

I want to learn how to design a beautiful, functional, intuitive website and so far everything has been easy to understand and made sense as to why I needed to know it. But I finished the "Introduction to Programming" section, coming out completely lost and am now working on "Javascript Foundations" and wondering — when am I going to actually need to do all this mathematical stuff? I'm not seeing any use for this unless you're doing something in the back end with databases (maybe)?

I know Javascript can do some interesting animation type stuff, like mouseovers and random order of images when a page is refreshed (if I'm remembering right from my college days) but I'm not seeing anything like that being taught yet — maybe because it's now handled better by CSS or something — but I keep thinking maybe that's why we're learning all this math stuff... and then I go to the next video and it's just more of this counting...

Can someone tell me why we're learning this? Who uses this in web development (for what purpose, or what role, basically)? I'm trying to be a web designer; I don't want to write programs. Is this the wrong track for me?

I'm sure I sound very ignorant right now ;) but I honestly want to learn — even if it's learning that I spent my time in the wrong track and need to start over elsewhere! :)

The simplest answer may be: HTML is for structure CSS is for presentation JavaScript is for behavior

I think JQuery simplifies much about JavaScript as it offers many 'pre-built' options. (Sort of like Bootstrap simplifying via pre-built CSS layout options and buttons, etc.)

3 Answers

Erik McClintock
Erik McClintock
45,783 Points

Gina,

As Derick mentions, try checking out the JavaScript Basics course with Dave MacFarland. It might help to paint a clearer picture for you.

As far as who uses JavaScript and for what, the answer is relatively simple: if you will simply be designing websites and not building them, you don't need to know JavaScript (and technically, unless you're building interactive prototypes online, you wouldn't even need to know HTML/CSS at that point; you'd just need to know design principals and how to use software like Illustrator or Photoshop). If, however, you plan to build websites out after a design is agreed upon (whether your design or another designer's), then you will want to know JavaScript. Plain and simple! Of course, there are always ways of getting around that, like hiring a JavaScript developer to implement the interactivity in your website after you've built the style and structure with HTML and CSS, but that should be unnecessary with a little time and practice in the language yourself!

JavaScript is a front-end development language that is one of the three need-to-know legs for front-end development. You need HTML for structure, CSS for presentation, and (importantly) JavaScript for behavior. Sure, with CSS3, some things that used to be taken care of in JavaScript (animations and such) can be done within your stylesheets, but JavaScript is far from being down and out. Unless you want a very basic, static site, you're going to want to learn JavaScript.

It is not traditionally used for database interaction (for that, you would use a back-end language like PHP, Python, or Ruby, though JavaScript has begun creeping back to the server side with things like Node.js, which Treehouse has some classes on) or just for doing calculations and math (and to clarify what you've seen in the videos, I think Jim just uses integers as arguments in his examples, I don't think he's actually doing much math. He could just as easily have used strings or booleans, etc.), it is used for allowing client interaction with your web page. You will use it with forms, you can use it to add and remove classes for semantic and/or styling purposes on given events that JavaScript can watch for (such as user clicks, key strokes, state changes, etc.), you can use it to set timeouts and repeat processes and set intervals, you can change elements on the page depending on data passed to functions and variables that you've declared, etc. It is used to interact with the DOM, which is very important in modern websites. JavaScript (and any programming language, for that matter) can definitely be tough to grasp and confusing when you're just starting out, but don't be disheartened! As you practice, just as with HTML, CSS, software classes, etc., it will get easier and start making more sense.

The best thing you can do is seek out alternative methods of learning, especially if you're not getting it from a particular class here. I highly recommend also looking into Codecademy and the Head First series of books from O'Reilly Media as two other, different, and great resources. It's always best to learn from multiple sources, anyway, as things will be taught in slightly different fashions that a) you may understand better, and b) may show you other ways of doing things that you wouldn't have considered if you'd gotten all your information from one source.

To sum up: if you are going to be a front-end web developer, then you need to learn JavaScript. If you're going to be a designer that doesn't do any development, then you're probably fine without learning it.

Once you find the right resource to learn from, and once you start picking it up, its value will become crystal clear, and you will love the language and love using it. After you've gotten down the basics and understand what's going on with the language, you can then look into the ever-popular jQuery library, which will allow you to do a lot of things in a simpler fashion (in the sense that you will write less code to achieve the same goal). I was in your same boat before, and had to try a lot of different resources (such as the Head First books, codecademy, and Treehouse, amongst others) before things really started to stick. Now I work full time as a developer, both front and back-end, and I got that job after only a few months of hard work here on Treehouse. And I don't say that to gloat, but rather to help illustrate that it can be done, and it's not as tough as it may seem initially! I'm certainly no mathematician by any stretch of the imagination, and while I wish I was, it is not necessary to be for what you'll use JS for 99% of the time (particularly when it's used for web development). JavaScript helps your webpage and its visitors DO things, which is a very important part of the user experience...so give it a chance :)

Hope you find a resource that works well for you, and hope to see you back here with more JavaScript questions as you go along with the courses! Practice and ask questions where necessary, and you'll be a full-fledged web developer before you know it!

Happy coding!

Erik

Hahahaha Wow! Thanks man. I didn't ask the question, but if I did- best answer all around. Please know that you really did help SOMEONE with this essay of a response. Fantastically thorough and very inspiring!!!

Hi Gina,

I totally felt the same way when I started that course a while back! I really felt like it's aimed more at aspiring programmers than designers. However as an aspiring front end developer myself (after diving deeper into the realm of JS and jQuery) it actually started to make a lot of sense over time. JavaScript can do a crap load of things other than cool effects on a webpage. I think that's what they were aiming at with that course, to just exemplify the capabilities of the language if you're an advanced coder and working on a complicated web app or something. Honestly, you probably won't use most it lol.

Personally, I didn't find a lot of it handy but try taking the jQuery course, if cool aesthetics and interactivity is your goal then jQuery and some CSS3 will do you just fine :) Also check out the NEW JavaScript course with Dave McFarland, another person in the forum here told me it's a lot more simplified and aimed more at front end developers and designers rather than full fledge programmers. Anyway hope this helps!

Hi Gina,

JavaScript is used by front-end developers in myriad ways to enhance the behavior and performance of webpages. It is an important tool used for things like loading new page content without reloading the page (i.e. posting to Facebook), and validating input values of web forms before submitting them server-side. It is an incredibly robust language that can communicate both with the client and the server.

If your goal is to be a classic 'web designer', you may simply be better off diving deeper into Photoshop, Illustrator, HTML5, CSS3, Bootstrap, and Sass. This is less programming oriented and more aesthetically focused. Continuing on this track won't hurt, but your time may be better served focusing more so on design rather than front-end.