Engineering
What is JavaScript? A plain guide for beginners
JavaScript is the programming language that makes websites interactive. Here's what it does, how it works with HTML and CSS, where it runs, and how to start learning it for free.
Hexer
Co-Founder & CEO
6 min read

JavaScript is a programming language that makes websites interactive. HTML gives a page its content, CSS gives it its look, and JavaScript makes it respond to you: menus that open, forms that check what you typed, chats that show new messages without reloading. It runs in every major web browser, and today it also runs on servers, in phone apps and in desktop apps.
It's also everywhere. According to W3Techs, about 98.9% of all websites use JavaScript. If you've used the web today, you've used it.
What JavaScript does on a page
Without JavaScript, a web page is mostly a document. You can read it and click links, and every click loads a whole new page.
With JavaScript, the page can react while you're on it. A few things you've probably seen this week:
A payment form that checks your number. You type your mobile money number, and before you press Pay, the page tells you it's one digit short.
A cart that updates in place. You tap Add to cart and the little number on the cart icon goes from 1 to 2. The page doesn't reload.
A chat that keeps up. New messages appear as they arrive, and you see "typing..." while the other person writes.
A menu that opens and closes. On a phone, you tap the three lines in the corner and the menu slides out.
Each of these is a small program, written in JavaScript, running inside your browser.
How HTML, CSS and JavaScript fit together
Most web pages are built from three languages, and each has one job.
HTML says what's on the page: a heading, a paragraph, a button.
CSS says how it looks: the colours, the fonts, the spacing.
JavaScript says what happens: what the button does when you tap it.
Here's a button built with all three. The HTML puts it on the page:
1<button id="greet">Say hello</button>
The CSS makes it blue:
1 2 3 4#greet { background: #0041cc; color: white; }
And the JavaScript makes it do something when you tap it:
1 2 3 4 5const button = document.getElementById("greet"); button.addEventListener("click", () => { alert("Hello from JavaScript!"); });
The first line finds the button on the page. The rest says: when someone clicks it, show a message.
A few lines of real JavaScript
You don't need to understand everything in this example yet. Just notice how much of it reads like plain English.
1 2 3 4 5 6 7 8 9const price = 180; const delivery = 25; const total = price + delivery; if (total >= 200) { console.log("You get free delivery!"); } else { console.log("Add a little more to get free delivery."); }
const creates a name for a value, so price means 180 from then on. The if checks a condition and picks what to do. console.log prints a message for the developer to see. Here the total is 205, so it prints "You get free delivery!"
Here's the payment-form check from earlier, as a function you can reuse:
1 2 3 4 5 6function looksLikeAPhoneNumber(number) { return number.length === 10 && number.startsWith("0"); } looksLikeAPhoneNumber("0241234567"); // true looksLikeAPhoneNumber("024123"); // false
A function is a set of steps with a name. You write it once and use it as often as you like.
Try it yourself in 30 seconds
You already have everything you need to run JavaScript: a web browser.
- Open Chrome or Edge on a computer.
- Press Ctrl + Shift + J (on a Mac, Cmd + Option + J). A panel called the Console opens.
- Type
2 + 2and press Enter. You'll see4. - Now type
alert("Hello!")and press Enter. A message pops up on the page.
That's real JavaScript, running in your browser. On a phone, search for an online JavaScript playground and type the same lines there.
Where JavaScript runs
In the browser. This is where it started, and it's still the only programming language that runs natively in every major browser. Each browser has a built-in engine that reads and runs JavaScript.
On servers. Since Node.js arrived in 2009, JavaScript can also run outside the browser, on the computers that send web pages and store data. That means one language can cover both the page you see and the system behind it.
In phone and desktop apps. Tools exist that turn JavaScript into apps you install on Android, iPhone, Windows or Mac. Plenty of apps you use every day are built this way.
JavaScript is not Java
This trips up a lot of beginners. Java and JavaScript are two different languages that share part of a name, and not much else.
The name was mostly marketing. JavaScript was created at Netscape in 1995, when Java was the most talked-about language around. It was first called Mocha, then LiveScript, and in December 1995 it was renamed JavaScript to ride Java's popularity.
A very short history
Brendan Eich wrote the first version of JavaScript in about ten days in May 1995, while working at Netscape on its web browser. In 1997 the language was standardised under the official name ECMAScript, so that every browser would run it the same way.
Since 2015, a new version of the standard has come out every year. Each one adds a few features, and old code keeps working. That's a big reason JavaScript is still the language of the web thirty years later.
Is JavaScript hard to learn?
It's one of the friendliest first languages there is. You need nothing but a browser, you see results immediately, and when you get stuck, millions of people have asked the same question before you.
The tricky part isn't the language itself. It's that there's so much built around it that beginners try to learn everything at once. Don't. Get the basics solid first:
Values and variables: numbers, text, true and false, and giving them names.
Conditions and loops: making decisions, and repeating steps.
Functions: wrapping steps so you can reuse them.
Arrays and objects: keeping lists and grouped information together.
The page: finding elements, changing them and responding to clicks.
Fetching data: getting information from somewhere else without reloading.
AI tools can write a lot of JavaScript for you now, and they're great teachers when you ask them to explain. But you still need the basics to know whether what they wrote is right. We wrote about why those skills matter more now, not less.
How to start learning, for free
MDN's JavaScript guide, from Mozilla, is the reference most professional developers use. It's thorough, free and kept up to date.
javascript.info teaches the language step by step, from the very first line to advanced topics.
freeCodeCamp has free courses where you write code in the browser and build small projects as you go.
Then build something small that you'd actually use. A page that splits a bill between friends. A to-do list. A quiz for your class. You'll learn more from one finished project than from ten tutorials you only watched.
Quick answers
Is JavaScript free? Yes. It costs nothing to write or run, and every browser includes it.
Do I need to install anything? No. A web browser is enough to start. Later you'll want a code editor, and the popular ones are free.
Can I build an app with JavaScript? Yes. Websites, web apps, servers, and phone and desktop apps can all be built with it.
Is JavaScript the same as Java? No. They're different languages with similar names.
What should I learn first, HTML or JavaScript? Learn a little HTML and CSS first, so you have a page for your JavaScript to work with. A week or two is enough to get started.
From Hexerize
See what we're building.
Hexerize is a technology company from Ghana. Take a look at our apps, or get in touch.


