Introduction

JavaScript is a high-level programming language that runs in every web browser, adding interactivity and behavior to websites, and also powers servers, apps, and tools through runtimes like Node.js.

Learn Python, JavaScript, Java and more with free interactive lessons, real projects and AI-powered help. Beginner-friendly.

Part of the free JavaScript course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.

Welcome to JavaScript — the world's most popular programming language for creating interactive websites, apps, and even servers.

Unlike most programming languages, you do not need to install anything to run JavaScript. Every web browser (Chrome, Firefox, Safari, Edge) has JavaScript built in!

If you have a web browser, you can already run JavaScript!

You can practice directly on this website using the "Try It Yourself" sections — no setup needed!

Open your browser's Developer Tools to run JavaScript instantly:

You should see Hello, World! appear in the console!

Open any text editor (Notepad, TextEdit, VS Code) and save a file as:

Double-click the file to open it in your browser. You will see an alert popup!

Node.js lets you run JavaScript outside the browser — useful for building servers and tools.

Visit nodejs.org and download the LTS version.

Real-World Analogy: Think of building a webpage like putting on a play:

Without JavaScript, your webpage would be like a stage with no actors — static and unable to respond!

JavaScript (JS) is the core language of the modern web . Every time you click a button, open a dropdown, or see a game running in your browser — JavaScript is behind it.

Together, these three form the foundation of web development .

When you type something into a website search bar, submit a form, or click a menu that expands — JavaScript code is what makes it happen instantly without reloading the page .

In JavaScript, you use the console.log() function to show output (messages, results, or test results). Let's start with the classic "Hello, World!" example.

When you run this line, your output will appear in the console (the output section below).

Congratulations — you just ran your first JavaScript program! 🎉

Let's go through the most important building blocks one by one.

Comments are notes you write for yourself or other developers . They are ignored by the computer.

💡 Tip: Writing good comments helps you and others understand your thought process when revisiting code later.

Used to display output or debug your program.

👉 Debugging means finding problems (bugs) in your code. console.log() helps track what's happening inside your program at different points.

A string is any text enclosed in quotes. JavaScript allows:

💡 Template literals (the ones with backticks let name = "Alice"; console.log(\ } 🟦 Numbers and Booleans Numbers in JavaScript can be integers or decimals :

Booleans represent true or false values, used for conditions and logic:

💡 Best Practice: Always use const unless you know the value will change.

JavaScript can perform all common math operations.

✅ Use these for calculators, finance tools, or even game logic.

Semicolons ( ; ) mark the end of a statement. They are optional in JavaScript but strongly recommended for clarity.

It's good habit to use them consistently — especially in larger apps.

Besides console.log() , JavaScript can display output in other ways:

alert() is good for quick tests. document.write() is rarely used in modern code but useful for learning basics.

JavaScript is case-sensitive , meaning Name and name are not the same variable.

Keywords are reserved words that have special meaning (like let , const , if , function ). Identifiers are names you choose for variables, functions, etc.

JavaScript runs top to bottom — each line in order, unless you use loops or conditions.

Here are some of the most frequent errors new coders face:

Use the browser console to test small snippets. Open Developer Tools → Console (F12 or right-click → Inspect → Console tab) and type:

You can run JavaScript directly from there — perfect for practice and experimenting.

You've taken your first step into JavaScript! You now know how JS runs in the browser, how to use console.log() , and the basic data types.

Up next: Variables & Data Types — how to store and name any piece of data your program needs! 📦

Practice quiz

Which built-in function does this lesson use to print output to the console?

  • print()
  • console.log()
  • echo()
  • document.print()

Answer: console.log(). console.log() is the method used to display messages, numbers, or values in the console.

What type of value is "Hello, World!" in JavaScript?

  • A number
  • A boolean
  • A string
  • An object

Answer: A string. Text wrapped in quotes is a string.

According to the lesson, why don't you need to install anything to start running JavaScript?

  • It must be downloaded from nodejs.org first
  • Every web browser has JavaScript built in
  • It only runs after compiling
  • You need Visual Studio

Answer: Every web browser has JavaScript built in. Every browser (Chrome, Firefox, Safari, Edge) has JavaScript built in.

Which keyword creates a variable whose value cannot be reassigned?

  • let
  • var
  • const
  • def

Answer: const. const creates a variable that cannot change; the lesson recommends using it by default.

What does the modulo operator a % b return?

  • The quotient
  • The remainder
  • The product
  • The power

Answer: The remainder. % returns the remainder of a division, e.g. 10 % 3 is 1.

Which three technologies form the foundation of web development per the lesson?

  • HTML, CSS, JavaScript
  • HTML, PHP, SQL
  • Java, CSS, Python
  • React, Vue, Angular

Answer: HTML, CSS, JavaScript. HTML is structure, CSS is style, and JavaScript is behavior.

Which of these starts a single-line comment?

  • /* */
  • #
  • //
  • <!-- -->

Answer: //. // begins a single-line comment; /* */ is for multi-line comments.

Because JavaScript is case-sensitive, Name and name are...

  • The same variable
  • Two different variables
  • Both reserved keywords
  • Always equal to null

Answer: Two different variables. JavaScript is case-sensitive, so Name and name are distinct variables.

Which feature lets you insert variables directly inside a string using ${ }?

  • Double quotes
  • Single quotes
  • Template literals (backticks)
  • Comments

Answer: Template literals (backticks). Template literals (backticks) allow string interpolation with ${ }.

What does the lesson say about how JavaScript runs your code?

  • Bottom to top
  • In random order
  • Top to bottom, line by line
  • All lines at once

Answer: Top to bottom, line by line. JavaScript runs top to bottom, executing each line in order unless loops or conditions change the flow.