What is JavaScript

JavaScript is a type of programming language: basically, a way to give instructions that a computer can understand. It’s used to make websites interactive.

When you click a button, fill out a form, or see part of a page update without reloading, that’s usually JavaScript at work. While HTML creates the basic structure of a webpage and CSS makes it look nice, JavaScript adds the “action.” It’s what makes websites responsive, allowing them to change based on what you do.

Examples

Code snippet

What it does

alert(“Hello, world!”);

Displays a pop-up message in the browser

document.getElementById(“title”).textContent = “Updated!”;

Changes the text of an element with the ID “title”

if (loggedIn) { showDashboard(); }

Runs a function if the user is logged in

const items = [“apple”, “banana”, “cherry”];

Creates an array of three items

A brief history

JavaScript was created by Brendan Eich in 1995. It was originally developed in just 10 days and was first called Mocha, then LiveScript, and finally JavaScript.

At first, it was a simple scripting tool used to add basic interactivity to web pages. But over time, it has grown into a powerful programming language used for everything from building user interfaces to running backend servers.

Today’s JavaScript (especially versions from ES6 onward) includes advanced features like classes, modules, promises, and async/await, making it a core technology in modern web and software development.

Good to know

Despite the name, JavaScript is not related to Java. JavaScript is supported in every major web browser and doesn’t require any installation to run in the browser. It can interact with HTML and CSS through the Document Object Model (DOM), which lets developers change what’s shown on a page without reloading it.

Know more

Frequently Asked Questions

Is JavaScript the same as Java?
No. Despite having similar names, JavaScript and Java are completely different languages with different use cases, syntax, and history.
Can JavaScript run outside a browser?
Yes! Originally, JavaScript was only for browsers. But now, thanks to tools like Node.js, it can also be used on servers. So JavaScript can power both the front end (what users see) and the back end (behind-the-scenes logic).
Do I need to install anything to run JavaScript?
You don’t need to install anything to use browser-based JavaScript. Just open your browser's developer console. For server-side JavaScript, you'll need something like Node.js installed.
What is the DOM in JavaScript?
The Document Object Model (DOM) is a way for JavaScript to interact with the structure of an HTML document, allowing it to read and change page content dynamically.