JavaScript: The Complete Language Guide
Chapter 1 / 7· 16 min read· 0 cards

What is JavaScript and Running Your First Code

Why JavaScript is everywhere, where it runs, and your first lines of code.

The language that runs the world's software

JavaScript is, by most measures, the most popular programming language on the planet — and for good reason. It started as a small language to add interactivity to web pages, but it grew into something enormous. Today, JavaScript runs every website in your browser, powers servers and APIs through Node.js, builds mobile apps (React Native), desktop apps (like VS Code and Discord, built with Electron), and even controls hardware. Learn JavaScript well, and you can build almost anything, almost anywhere.

This course teaches JavaScript as a language — the core skills that work everywhere it runs. Whether you go on to build websites with React, servers with Node, or apps, the foundation is the same JavaScript you'll learn here. (Our Web Development course covers using JavaScript specifically to make web pages interactive; this course goes deeper into the language itself.)


Where JavaScript runs

Unlike languages you compile and run as files, JavaScript runs inside a host environment. The two you'll meet are:

  • The browser — every browser has a JavaScript engine built in. This is where JavaScript began, controlling web pages.
  • Node.js — a program that runs JavaScript outside the browser, on your computer or a server. This is what lets JavaScript build back ends, tools, and command-line programs.

The beautiful thing is that the core language is identical in both. The playground in this lesson runs your JavaScript instantly so you can experiment as you learn, no setup required.


Your first JavaScript

JavaScript's first program couldn't be simpler — printing a message:

console.log("Hello, world!");

console.log() prints whatever you give it. In the browser, "the console" is a panel in the developer tools (press F12 to open it); in Node, it prints to your terminal. console.log is your constant companion — it's how you see what your code is doing and debug problems. You'll use it thousands of times.


Variables: let and const

A variable is a named container for a value. Modern JavaScript uses two keywords to declare them: let for values that can change, and const for values that won't:

let score = 0;          // can be reassigned later
score = 10;             // fine

const name = "Mehul";   // a constant — cannot be reassigned
// name = "Riya";       // ERROR — can't reassign a const

let city = "Ahmedabad";
console.log(name + " from " + city);   // Mehul from Ahmedabad

The modern best practice is simple: use const by default, and let only when you genuinely need to reassign the variable. This makes your intent clear and prevents accidental changes. You may see an older keyword var in old code — avoid it; let and const are the safer, modern choices and the only ones you should write.


JavaScript is dynamically typed

Unlike Java or C, you don't declare a variable's type in JavaScript — you just assign a value, and JavaScript figures out the type. A variable can even hold different types at different times (though that's usually not a good idea):

let x = 42;        // x is a number
x = "hello";       // now x is a string — JavaScript allows this
console.log(typeof x);   // "string" -- typeof tells you the type

This flexibility makes JavaScript quick to write, but it also means you must be a little careful — there's no compiler to catch type mistakes before you run. The typeof operator lets you check a value's type whenever you're unsure. With variables understood, the next chapter explores JavaScript's data types and operators in depth.

Reading mode · scroll to read at your own pace

Finished "What is JavaScript and Running Your First Code"?

Mark this chapter complete so you can pick up exactly where you left off. Your progress saves locally — sign in to sync across devices.

Was this chapter clear?

Try it yourself — open the Code Playground15+ languages — Python, JavaScript, Java, C++, SQL & more — full IDE-style editor, instant run. Your code is auto-saved per language.