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

Sarah Breidenbach
Sarah Breidenbach
4,490 Points

What are the most common reasons to use JavaScript?

I know JavaScript is intended to make a website interactive, that without it websites are considered static. What sort of things need to be interactive? What are the most common reasons to use JavaScript? I liked the DOM Scripting By Example course about building an RSVP web application because it showed something real that you could use JavaScript for on a website. What specific things do you need to use JavaScript for on a regular basis on websites? I'm especially interested in what a front-end developer should be able to do in order to freelance solo.

JavaScript is an extremely dynamic language that has tons of uses. On websites, it handles things like events (clicks, mouseover, mouseout, keypress, etc.), animations, form submission, and so much more. You can use it to do things like count every time a user visits the site, turn an element a different color when it is scrolled over, to extend a line under some text when the page loads, to add text or new elements to a page when an event occurs, or delete elements on a page when another event occurs. There's tons more you can do, it would just take too long to list. Believe it or not, JavaScript's uses are not limited to front end development. It can be used for back end development if php isn't really your thing, you can even build a firewall with it. And that's just raw JavaScript, not mentioning the hundreds of JS libraries out there. Those are just a few of the best uses for JavaScript, Sarah.

2 Answers

Sarah Breidenbach
Sarah Breidenbach
4,490 Points

Thanks for responding. I guess I was hoping for something a bit more specific. So far the things I've found JavaScript necessary for (that I can't do with CSS) are clickable buttons, accordions, slideshows, obscuring email addresses from bots, dialog boxes, animations initiated by events and form validation. Is there anything else developers use regularly that you would add to this list? I'm looking for basic "need to know" type things or things that might be expected of me as a freelancer. I've finished the basic JavaScript track but I'm not sure how to apply most of what I've learned to the necessities of front-end development.

Well if you're having trouble thinking of ways you can use it, try this: Think about your ideal website, think about all the features it would have and how you could use JS to create those features. That would be my best advice.