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

Philip Bradbury
Philip Bradbury
33,368 Points

What can JavaScript do??

I’ve been struggling with this for a while... What can JavaScript do/ used for. I know it’s for site interactions, nav, lightbox ect and that the library jQuery is used for stuff like that. I want to know though what else can I do with JavaScript? I’ve googled it but it’s not much help. I feel I’m getting a good grasp with the language but not overly sure what I can do with it and its holding me back a little.

Thanks

Phil

4 Answers

JavaScript can do everything. :) No, seriously, what started as a way to do some scripting inside the browser soon expanded to all kinds of purposes.

Inside the browser, JavaScript is a source of interactivity. With the DOM API it can manipulate DOM elements, giving it the ability to do all the things you've mentioned and much more. You can also use it to load data asynchronously through XMLHttpRequests, server-sent events or websockets. The last two allow you to make modern web applications that update their content as changes happen on the server, without having to ask the server for changes. Although, it's impossible to list all the things that JavaScript does on the browser.

It might be important to mention that JavaScript is also used to write browser extensions and desktop widgets. You can use it to write Windows 8 apps. Or you can write them for all the major platforms using node-webkit.

You can use it to write computer games. For example, Unity 3D uses JavaScript as one of its languages. There are numerous other game engines leveraged by or even completely written in JavaScript.

You can make cross-platform mobile apps with JavaScript by using Titanium or Cordova/PhoneGap or Steroids. There are more of these frameworks, these are just the ones that I could remember.

Finally, you can use it on the server side, to help out your app written in PHP/Ruby/Java/something, or even completely replace an app in a different programming language. The most popular of these solutions is node.js, but there are others like JXcore or Vert.x.

I should also probably mention databases like MongoDB that are scripted with JavaScript.

So, by using some of the technologies I've mentioned here, you could write a web app which uses a database, both desktop and mobile client apps without ever switching programming languages.

Of course in the end, when writing an app, you'll use the technologies that best suit you and work best for the app, so going all-JavaScript might not be the best solution, but it is a solution.

James Barnett
James Barnett
39,199 Points

Basically has 3 parts:

  • content (HTML)
  • presentation (CSS)
  • behavior (JavaScript)

JavaScript basically adds interactivity to your page.

read more here: http://javascript.about.com/od/reference/a/javascriptpurpose.htm

The answer is that JavaScript can do a lot of things. It even has server-side aspects. Node.js is just one very popular software platform for making web applications.

You might take it a bit further with books like JavaScript: The Definitive Guide and Professional JavaScript for Web Developers.

JavaScript is the programming language of the Web. The overwhelming majority of modern websites use JavaScript, and all modern web browsers—on desktops, game consoles, tablets, and smart phones—include JavaScript interpreters, making Java- Script the most ubiquitous programming language in history. JavaScript is part of the triad of technologies that all Web developers must learn: HTML to specify the content of web pages, CSS to specify the presentation of web pages, and JavaScript to specify the behavior of web pages. —David Flanagan

Philip Bradbury
Philip Bradbury
33,368 Points

Thanks guys think i need to do a lot of reading on it. Treehouse is great but i think its because its at a beginner level i can't see how to use the code for more advance operations (for people without Gold). Some JavaScript Intermediate or Advance would be awesome. I think it could be that its used with so many different libraries. Again thank you for the advice.

James Barnett
James Barnett
39,199 Points

For some practice you can get started with with some JavaScript projects

There some more ideas of what you can do with JavaScript over on Learn Street