JavaScript Tutorial

JavaScript Introduction

JavaScript is the language that makes a page respond: clicks, forms, lists, and live updates in the browser.

What is JavaScript?

JavaScript is a programming language that runs in the browser. HTML describes structure. CSS describes appearance. JavaScript describes behavior: what happens when someone clicks, types, or submits a form.

You already use JavaScript every day. A menu that opens, a total that updates, a quiz that scores itself — those are scripts talking to the page.

A first script

This page writes a line into the document and prints the same line in the console. Copy it into the JavaScript editor and click the heading.

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Hello JavaScript</title>
</head>
<body>
  <h1 id="title">Hello, JavaScript</h1>
  <script>
    console.log("The script ran.");
    document.getElementById("title").textContent = "The page just changed.";
  </script>
</body>
</html>

Click Try it in JavaScript under the example. That opens /javascript/try — a live page on the right and a console under it.

What JavaScript is for

  • Respond to clicks, typing, and form submit
  • Change text, styles, and lists on the page without reloading
  • Store small values in the browser with localStorage
  • Load JSON from a URL with fetch

It is not HTML. It is not CSS. A page can exist without JavaScript. JavaScript cannot draw a page without HTML to attach to.

console.log vs the page

console.log writes to the console pane in the StudyGrid editor. ChangingtextContent writes onto the page. Beginners mix these up: they log a message and wonder why the heading did not change.

Example

console.log("This is the console.");
document.body.textContent = "This is the page.";

JavaScript vs the other StudyGrid tracks

PythonHTMLJavaScript
Dashboard/tutorial/html/javascript
Editor/try/html/try/javascript/try
ResultPrints and plotsA rendered documentA page plus a console
File.py.html.js inside .html

What you will cover

  • Variables, types, strings, numbers, and arrays
  • Functions, objects, if/else, and loops
  • The DOM, events, storage, and fetch
  • Ten small apps you can finish in the editor

Next: where to put a script in a page, then how to print a result.

FAQ: JavaScript Introduction

Common questions about this page.

What is the StudyGrid JavaScript tutorial?

The StudyGrid JavaScript tutorial is a full beginner track: variables, functions, arrays, if/else, the DOM, events, storage, and fetch. Each chapter has copy-and-run examples.

Should I run javascript introduction examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn javascript introduction in this JavaScript JavaScript lesson (JavaScript Introduction).

Is the JavaScript editor the same as Try Python?

No. Try JavaScript is a live page plus a console at /javascript/try. Try Python stays at /try. JavaScript lessons never open the Python editor.

Do I need to install anything to learn JavaScript?

No. Open a chapter, click Try it in JavaScript, and the page and console update in the browser.

Where should I start the JavaScript tutorial?

Start at JavaScript Intro, then Where To, Output, and Syntax. After variables and functions, continue to the DOM and events. Use Next at the bottom of each chapter.

Is the JavaScript tutorial free?

Yes. The JavaScript studio on StudyGrid (studygrid.in) is free: dashboard, chapters, and the live editor.