AniUI Academy

What Is JavaScript

What the language actually is, why it has a misleading name, where it runs besides the browser, and what you can realistically build once you know it.

8 min read

You now know how a page gets to you and which of three languages does what. This lesson is about the third one specifically: what it is, where it came from, and what it can actually do.

The short answer

JavaScript is a programming language that runs inside your browser, so that a web page can respond to what you do instead of just sitting there.

That was the original purpose and it is still the main one. But the language escaped the browser years ago and now runs on servers, in phone apps, on tiny hardware devices and in build tools. Learn it once and a lot of doors open, which is a large part of why it is worth your time.

Where the name came from

The name causes real confusion, so let us clear it up immediately.

JavaScript is not related to Java. They are separate languages with separate designs, made by different people for different reasons. JavaScript was created in 1995, in about ten days, and was originally called Mocha, then LiveScript. Java was popular that year, so it was renamed JavaScript as a marketing decision. That is the entire connection.

This matters practically. Searching for a Java answer when you have a JavaScript problem will waste your afternoon, and the two show up side by side in search results constantly.

You will also see ECMAScript, usually shortened to ES. That is the official written standard the language follows. JavaScript is what everyone calls the thing that implements the standard. When you see "ES2015" or "ES6", that is a version of the specification — ES2015 in particular added a large batch of features, including const, let and arrow functions, which is why it gets mentioned so often.

Where it runs

The language itself is small and portable. What changes is the environment it is dropped into, and each environment hands it a different set of tools.

In the browser

The original home. Here it can read and change the page, respond to clicks and typing, store small amounts of data, and talk to servers. It cannot touch your files or your other tabs.

On a server, with Node.js

The same language outside a browser. Here there is no page at all, but it can read and write files, connect to databases, and answer requests from browsers. This is how one person can build both halves of a site.

Everywhere else

Phone apps through React Native, desktop apps through Electron, build tools, automation scripts, and even small hardware devices. All the same core language.

This explains something that confuses beginners badly. A tutorial's code fails on your machine with something like document is not defined, and nothing seems wrong with it. Usually the code was written for a browser and you ran it in Node. document is the page — and on a server there is no page. The language was identical; the surroundings were not.

What it can do in a page

Concretely, in the browser, JavaScript can:

  • Change the page. Add, remove and edit anything on screen while it is open.
  • React to people. Clicks, typing, scrolling, submitting a form.
  • Talk to a server. Fetch new data and show it without a reload — this is what makes a feed load more as you scroll.
  • Remember things. Store small amounts of data in the browser so a preference survives a refresh.
  • Run timers and animation. Do something in three seconds, or on every frame.

And, just as importantly, what it cannot do:

  • Read files on your computer that you did not deliberately choose.
  • Look at other tabs or other sites' data.
  • Install anything or change your system.

Those limits are called the sandbox, and they are why it is safe to open an unfamiliar website. Its code runs on your machine within seconds of you arriving, and the browser makes sure it can only touch its own small world.

What people build with it

Worth being honest about the range, because "learn JavaScript" is vague until you see where it goes.

Interactive pages are the floor: forms that validate as you type, menus, tabs, search that filters as you type. Above that, full applications that run in a browser — editors, dashboards, whole design tools. Then server code with Node, handling sign-ins and databases. Then phone apps with React Native, which is a separate track here later. And a large amount of unglamorous, genuinely useful automation: scripts that rename a thousand files or check a hundred links.

You do not need to pick now. The core you are learning is the same for all of them.

It is a real programming language

One misconception worth killing early: JavaScript is sometimes described as a "scripting language", said in a tone that implies it is a lesser thing.

It is a full programming language. It has functions, objects, error handling, modules, and a large standard library. Enormous applications are built in it. It has genuine rough edges, inherited from being designed in ten days and then never being allowed to break the millions of sites depending on its mistakes — you will meet a few in this course and we will not pretend they are elegant. But it is a serious tool, and the skills transfer to other languages.

Your first look at running code

You have not been taught any syntax yet, so read this as English rather than as code. It uses a few things you will learn properly over the next lessons.

Try it yourself
Loading playground...

Press Run. Three things are happening: two names are given values, some text is printed, and a decision is made based on a number. Change lessonsDone to 0 and run it again — the last message changes, because the decision now goes the other way.

That is a program. Data, and decisions made from it. Everything else is a variation on that.

console.log prints a message where a developer can see it. It is not visible on the page itself, and it is the single most used debugging tool in the language — you will type it thousands of times.

What to take away

JavaScript is the language browsers run, unrelated to Java, standardised as ECMAScript. The same language runs on servers through Node and in phone apps through React Native; what changes between them is the tools the environment provides, not the language. In a browser it can change the page, react to people, and talk to servers, and it is sandboxed away from your machine.

Next: what actually happens inside the browser when your code runs, and why JavaScript can only do one thing at a time.

Check yourself

4 questions · pass 3/4 to unlock How JavaScript Runs Your Code

up to 50
  1. 1.What is the relationship between JavaScript and Java?

  2. 2.What is ECMAScript?

  3. 3.Which of these can JavaScript NOT do when running in a normal web page?

  4. 4.Why does the same JavaScript sometimes behave differently in Node than in a browser?

4 left to answer