JavaScript is the programming language of the web. Every interactive website you’ve ever used — clicking buttons, loading new data without refreshing, updating a shopping cart — that’s JavaScript running in the browser.
Copy
// This runs in the browserdocument.querySelector("button").addEventListener("click", () => { console.log("Button clicked!");});// This runs on the server (with Node.js)const express = require("express");const app = express();app.listen(3000);
JavaScript started as a browser-only language in 1995. Today it runs everywhere — browsers, servers (Node.js), mobile apps, and even desktop applications. For web development, it’s not optional. HTML gives you structure, CSS gives you style, and JavaScript gives you behavior.
In this course, you’ll use JavaScript for two things: building React frontends and connecting them to your FastAPI backend. That covers the vast majority of what full-stack web developers do with JavaScript.
You already know how to program. JavaScript and Python share the same core concepts — variables, functions, loops, objects. The differences are mostly syntax.
# Python equivalentdef greet_user(name): message = f"Hello, {name}!" print(message) return messageusers = ["Sarah", "John", "Alice"]for user in users: greet_user(user)
The logic is identical. The wrapping is different. Here are the key differences you’ll notice right away:
Feature
Python
JavaScript
Variables
name = "Sarah"
const name = "Sarah";
Functions
def greet():
function greet() {}
Blocks
Indentation
Curly braces {}
Strings
f"Hello, {name}"
`Hello, ${name}`
Print
print()
console.log()
None/null
None
null (and undefined)
Naming
snake_case
camelCase
Don’t try to memorize every difference up front. You’ll pick them up naturally as you write code. The table above covers 90% of what trips people up in the first few days.
const name = "Sarah";const age = 25;console.log(name); // "Sarah"
Semicolons end each statement. JavaScript can technically guess where they go (called “automatic semicolon insertion”), but always include them. It avoids subtle bugs and every serious codebase uses them.
Curly braces {} define blocks of code — function bodies, if/else branches, loops. Indentation is optional (but you should still indent for readability).
const userName = "Sarah";const UserName = "John";const USERNAME = "ALICE";// These are three different variablesconsole.log(userName); // "Sarah"console.log(UserName); // "John"console.log(USERNAME); // "ALICE"
JavaScript is case-sensitive. userName, UserName, and USERNAME are three completely different variables. The convention is camelCase for most things, PascalCase for React components, and UPPER_CASE for constants.
const name = "Sarah";console.log(`Welcome to JavaScript, ${name}!`);
Copy
node hello.js# Welcome to JavaScript, Sarah!
Use the browser console to test quick ideas and one-liners. Use Node.js for anything you want to save or build on. You set up Node.js in the Getting Started section.
Now that you know how JavaScript fits into web development and how its syntax compares to Python, let’s start writing real code. First up: storing data in variables.