I don't understand what I should be doing with JavaScript

I’ve been programming and I’ve learned a decent amount from it. I got the first 2 certifications and I’m reading through the book Eloquent JavaScript. I know most of the fundamentals and some intermediate stuff like DOM manipulation and some front end libraries. But there’s something very basic that I don’t understand: I don’t really get what I should be making or doing with JavaScript. I’m hoping someone can point me in the right direction.

I’m not particularly creative and I know my interests aren’t in visually designing a nice looking web page. I love programming and problem solving. But despite learning all of these tools, if I’m given a blank file on a code editor, I’d have no idea what to make from it. I don’t even understand what people mean when they say application development.

When I briefly first worked with python, it was very easy to just start writing code because raw_input made it easy to mess around with different ideas and everything was just… cleaner? Now that I have a modest amount of knowledge in javascript, html, css, I’d like to develop a more clear idea of what I should be aiming for and be able to practice it.

I’m not quite sure if this will answer your question, but will give it a try anyway:

Only HTML and CSS together allow you to create static web pages. Adding JavaScript on the front-end allows you to create dynamic web pages—i.e., the content on the page might be changing, but not because of user input necessarily. This can include stuff like animation, but can also be other things like clocks and timers. Basically anything that involves the content on the page changing in some obvious visual way that you programmed (again, not always because of user input, but some dynamic pages might very well respond to user input).

Adding a back-end (whether that’s in JavaScript or another language) allows you to create interactive web applications.

Usually in other languages, like Python for example, when you write an application, you’re starting with the proverbial “back-end”, i.e. the main application logic. Until you build a GUI (the user-facing “front-end”) separately to add on to it, everything is going through a console or terminal. For JavaScript (and web applications), that front-end is your browser.

To put it simply, a web application is an interactive application that runs in your web browser. In the old days of computing, applications used to be hosted entirely on your computer. Some applications today still follow that model—i.e., your Web browser itself is a good example, whether that’s Chrome, Firefox, Edge, or Safari. All of these are examples of desktop applications written natively for your OS. Web applications are designed to run inside that Web browser across the Internet. Examples of these include freeCodeCamp, Dropbox, Amazon.com, Netflix, Twitter, Facebook, etc, as they all fall within this definition. Any website that offers an interactive experience and allows you to do something on it is basically a web application. Naturally, the possibilities of a web application are only limited by your imagination.

4 Likes

This is an over simplification, but think of it this way:

HTML is for structure
CSS is for style
JavaScript is for behaviour

If a web page should do something, it’s usually JavaScript’s job.

1 Like

A fun little experiment that may help you understand how javascript is used.

[Note this assume you use Chrome].

  1. Open the developer console (View > Developer > Javascript Console)
  2. Select the menu at the top-right conrner
  3. Settings > Debugger > Disable Javascript.
  4. Refresh the page.

Now you’ll see how this page will be without Javascript.

For science, try doing the same on something like Facebook. :wink:

As they say:

You don’t know what you got, till its gone

2 Likes

Javascript is a programming language standard for the web. It also can be used in other use-cases such as NodeJS. This is where you write code in a file, then run it using the NodeJS runtime. In NodeJS you don’t have a DOM, or CSS, or HTML and you gain access to things like the file-system and npm libraries. In this regard NodeJS allows Javascript to be used as a general programming language, similar to Python.

The thing with Javascript in the browser is its in a “sandbox” for web-sites. It can’t access your file system, it can’t do that much to your system at all (for security). As it can’t “do that much” in terms of overall impact it feels somewhat limited when compared to something like Java. But when you run JS in something like NodeJS, you get a whole new world in terms of capabilities.

So onto the topic of what you can build with Javascript and the answer is basically anything, but it less about the language and more about other things, such as the run time environment, and system. For example, if you asked “can I build an app using Javascript?”, and I’d say yes, but not directly. IOS and Android both have different requirements to build an app, and neither directly support Javascript, so you would need to transpile/compile it or use some kind of framework. (I’m not well versed in this process)
Now if you had NodeJS and asked “can I build a game”, well maybe, but you’d need to build a game-engine on it, and odds are due to the nature of the language, and it might run super slow. (NodeJS is single threaded, and idk how it would interact with graphic drivers)

So, keep your mind open as to how JS could be used, the Web provides tons different apis. NodeJS provides a different runtime, and different apis, for different use-cases. Both have massive package manager support, which provides utilities for nodejs that can be added to client-side code. (via build, cdn, whatever)
There are tons of open source projects going on using JS, for JS, with JS on github

JS powers desktop software like VSCode via things like electron, runs complex web apps like Facebook, Google Docs, and supports the back-ends of thousands of companies around the world using NodeJS.

So, go out, and build something, anything you can think of, odds are you probably can do it with JS :smile:

1 Like