Library › JavaScript
⚡ JavaScript
What Does JavaScript Actually Do?
Every time you click a button, see a menu slide open or watch a counter tick up on a website, JavaScript is probably doing the work. In this guide you'll see, with pictures, what JavaScript actually does, where it runs, and you'll run your very first line of code. No experience needed.
1. A web page speaks three languages
Almost every web page is built from three languages that work as a team. A handy way to remember them is to think of a person:
- HTML is the skeleton: headings, paragraphs, images and buttons.
- CSS is the clothes: colors, fonts, sizes and layout.
- JavaScript is the brain: it reacts when you click, type or scroll, and changes the page while you're looking at it.
A page with only HTML and CSS is like a beautiful poster: nice to look at, but it can't respond to you. JavaScript turns the poster into something you can use.
2. What can JavaScript do?
Almost everything that moves or reacts on a website. A few examples you use every day:
- A "Show more" button that opens hidden text.
- A search box that suggests words as you type.
- Likes and comments that appear without reloading the page.
- Games, maps and video players that run in your browser.
They all follow the same simple pattern:
Try it right here. This little demo is real JavaScript running on this page:
Hello! I'm a normal paragraph.
And this is the code that makes it work. Don't worry about understanding every word yet; just notice the three steps from the picture above:
// 1. Something happens: the button is clicked
button.addEventListener("click", () => {
// 2. JavaScript runs…
clicks = clicks + 1;
// 3. …and the page changes
message.textContent = "You clicked " + clicks + " times!";
});
3. Where does JavaScript run?
JavaScript was created in 1995 by Brendan Eich at Netscape, reportedly in about ten days, to make web pages interactive. (Despite the name, it has nothing to do with the Java language; the name was mostly marketing.)
Today it runs in two main places:
- In your browser. Every modern browser has a built-in JavaScript engine that reads and runs JavaScript code. You don't need to install anything: if you can open a web page, you can run JavaScript.
- On servers. Since 2009, a tool called Node.js lets JavaScript run outside the browser too, powering the "back end" of many apps and websites.
4. How JavaScript reads your code
A JavaScript program is a list of instructions called statements. The engine reads them from top to bottom, one at a time, like following a recipe:
Notice two small details in each line:
console.log( … )means "show this in the console", a message window developers use to see what their code is doing.- The semicolon
;at the end marks the end of a statement, like a full stop at the end of a sentence.
5. Your first line of code
Time to run JavaScript yourself. Press the ▶ Run button and watch the output appear:
console.log("Hello, world! 👋");
console.log("I am learning JavaScript");
console.log(2 + 3);
Did you notice the last line printed 5, not "2 + 3"? Text inside quotes is shown exactly as written, but without quotes, JavaScript calculates the answer. You'll learn much more about this in a later guide on data types.
Your turn: click inside the code above, change the text to your own name, and press Run again.
Running JavaScript in your own browser
Every desktop browser has a built-in console where you can type JavaScript directly:
- Chrome / Edge on Windows: press Ctrl + Shift + J
- Chrome on Mac: press Cmd + Option + J
- Any browser: press F12 (or right-click → Inspect) and open the Console tab
Type console.log("Hi!") and press Enter. Congratulations: you've just written and run JavaScript! 🎉
Quick recap
- Web pages use HTML (structure), CSS (style) and JavaScript (behavior).
- JavaScript reacts to events (like clicks) and changes the page.
- It runs in every browser, and on servers with Node.js.
- Code runs top to bottom, one statement at a time.
console.log()shows messages, perfect for learning and testing.
Quiz: test yourself
1. Which language controls the colors and layout of a page?
CSS. HTML is the structure and JavaScript is the behavior.
2. What will console.log(10 + 5) show?
15, because without quotes JavaScript calculates the sum.
3. What will console.log("10 + 5") show?
10 + 5, because text in quotes is shown exactly as written.
4. In what order does JavaScript run these lines?
From top to bottom, one statement at a time.
Two new visual guides every week
Plus animated tech explainers on YouTube and Facebook.
More from the Library

Why CORS Errors Happen
The 'blocked by CORS policy' error explained with moving pictures: what an origin is, why browsers block, preflight requests and the server fixes that work.
Read with pictures →
What Is an API?
APIs explained like a restaurant waiter: see requests and responses travel, learn GET, POST, status codes and JSON, then make a real API call yourself.
Read with pictures →
How DNS Works
How does typing a name like resinfo.in find the right computer? Watch a DNS lookup travel from your browser to the root, .in and name servers, then try a live lookup yourself.
Read with pictures →