Skip to content

What is JavaScript?

Updated Nov 30, 20263 min readBased on official documentation
What is JavaScript?

In short

JavaScript is a programming language that makes web pages interactive. It runs inside web browsers and, through environments such as Node.js, on servers and other computers too. It is one of the most widely used languages in software development today.

JavaScript, often shortened to JS, is a programming language. A programming language is a set of rules you use to write instructions that a computer can follow. JavaScript is best known as the language that adds behavior to web pages, such as menus that open, forms that check your input, and content that updates without a full page reload.

How it works

JavaScript is a lightweight language. Its code is run by an interpreter or a just-in-time compiler, which is a program that reads the code and turns it into actions the computer can perform. You do not need to build a separate program before you run your code. You write the text, and the runtime executes it.

The language is dynamic. Values can change type while a program runs, and objects can be created and changed on the fly. JavaScript also supports several styles of programming, including imperative, functional, and object-oriented code. Functions are first-class, which means you can store them in variables, pass them to other functions, and return them as results.

Memory is handled for you. JavaScript uses garbage collection, a process where the runtime frees memory that a program no longer uses. You rarely need to manage memory by hand.

Where it runs

The most common place for JavaScript is the web browser. Every modern browser can run it, so code written for the page works for most visitors without extra installation. The browser also provides extra features for pages, such as access to the document structure. These browser features are separate from the language itself.

JavaScript is also used outside the browser. Node.js is an environment that runs JavaScript on a computer or server, which lets developers write back-end code, command-line tools, and build scripts in the same language they use on the front end. Other products, such as Apache CouchDB and Adobe Acrobat, also use JavaScript for scripting.

A simple example

Here is a small snippet that shows a function and a variable. It uses the built-in console to print a message.

const name = "reader";

function greet(person) {
  return "Hello, " + person + "!";
}

console.log(greet(name));

If you run this in a browser's developer console or with Node.js, it prints a greeting. The code defines a value, creates a function that builds a string, and then calls that function.

Common mistakes

A frequent question is whether JavaScript is related to Java. It is not. The two languages have different syntax, meaning, and uses. The name is mostly a historical accident, so treat them as separate tools.

Another common point of confusion is the difference between the language and the environment. Features such as the page document or network requests come from the browser or Node.js, not from JavaScript itself. When you look for help, check whether a feature belongs to the core language or to the host environment.

Beginners also sometimes compare values with the wrong operator. JavaScript has strict equality with three equals signs and loose equality with two. The strict form is usually the safer choice because it does not convert types before comparing.

Learning path

If you are new, start with a guided tour of how JavaScript is used on web pages, then move on to the core language. The official documentation includes beginner tutorials and a detailed guide for readers with some programming experience. Once the basics feel comfortable, you can explore objects, asynchronous code, and the prototype chain, which explains how objects inherit behavior from other objects.

JavaScript is also the language of many popular frameworks and libraries. Learning the core language first makes those tools easier to understand, because most of them are built on the same features.

FAQ

Is JavaScript the same as Java?

No. JavaScript and Java are different programming languages with different syntax, semantics, and uses. The similar name is mostly historical.

Do I need to install anything to run JavaScript?

Not for basic web work. Every modern web browser can run JavaScript, so you can open the developer console and try code right away. To run JavaScript outside the browser, you can install an environment such as Node.js.

Is JavaScript only for web pages?

No. It is best known for web pages, but it is also used in environments such as Node.js for servers and tools, and in some products like Apache CouchDB and Adobe Acrobat.

Is JavaScript hard to learn for beginners?

The basics are approachable, especially if you start with small examples. Understanding the language's dynamic behavior and asynchronous code takes more practice over time.

Sources

This page is based on the official documentation below. Read it for full detail.

JavaScript — official documentation ↗

JavaScript in the news

blozhikDeveloper news from across the web, explained. Every story links to its original sources.