JavaScript Introduction

Beginner
6 min read
Updated: Oct 2026
Programming language

What Is JavaScript?

JavaScript (JS) is the programming language of the web. It runs in every major browser and on servers with Node.js, adding interactivity to HTML and CSS pages—and powering APIs, tools, and apps beyond the browser.

Remember
Web trio:
  HTML  → structure
  CSS   → presentation
  JS    → behavior

Standard: ECMAScript (ES)
Engines: V8, SpiderMonkey, JavaScriptCore

Brendan Eich created JavaScript in 1995 for Netscape. Today it is an open ECMAScript standard used for front ends, backends, mobile apps, and more.

Why Use JavaScript?

HTML and CSS alone cannot react to clicks, fetch data, or update the page dynamically. JavaScript is the language that makes pages interactive.

NeedHow JavaScript helps
User interactionHandle clicks, forms, and keyboard input
Update the pageChange the DOM without a full reload
Talk to serversfetch / AJAX for APIs and live data
One language, many placesBrowser, Node.js, Deno, Bun, and tooling

How JavaScript Runs

An engine reads your code and runs it step by step:

StepWhat happens
1. LoadBrowser or Node loads your .js / <script>
2. ParseEngine turns source into executable instructions
3. RunStatements execute; console.log prints output
4. EventsCallbacks fire later (clicks, timers, network)

Hello, World!

Print a message to the console—in the browser or with Node:

JavaScript
console.log("Hello, World!");
HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Hello World</title>
</head>
<body>
  <h1>Hello World demo</h1>
  <p>Open DevTools Console (F12) to see the output.</p>
  <script>
    console.log("Hello, World!");
  </script>
</body>
</html>
Try It Yourself

How It Works

1. Script. The <script> block (or .js file) contains JavaScript statements.

2. Call. console.log(...) sends a value to the console.

3. Run. Open the page (F12 → Console) or run node demo.js in a terminal.

terminal
node demo.js

JavaScript vs HTML, CSS & Java

Clear up the most common mix-ups:

HTMLCSSJavaScript
Structure & contentPresentation & layoutBehavior & logic
Tags like <p>Rules like p { }Statements like console.log()

JavaScript vs Java

JavaScriptJava
Dynamic typing; runs in browsers & NodeStatically typed; JVM / Android
Created for the web (1995)Created for portable apps (1995)
Often written as .jsOften written as .java
Unrelated to Java despite the nameUnrelated to JavaScript

Where to run it

EnvironmentBest for
BrowserDOM, UI, front-end apps
Node.jsAPIs, CLIs, build tools, servers

Three Ways to Add JS

Pick the method that fits the job. External files are best for real sites.

MethodWhere it livesBest for
InlineEvent attributes like onclick="..."Quick one-off tests (avoid for large sites)
Internal<script> block in the HTML pageSingle-page demos and learning
External.js file + <script src="app.js">Reusable site-wide scripts
HTML
<script src="app.js"></script>

Place scripts near the end of <body> (or use defer on external scripts) so the HTML is ready before your code runs.

Core Building Blocks

These pieces show up in almost every beginner program:

ConceptWhat it doesExample
VariablesStore valueslet name = "Asha";
FunctionsReusable blocks of codefunction add(a, b) { }
ConditionalsBranch on true/falseif (n > 0) { }
LoopsRepeat workfor (let i = 0; i < 3; i++)
DOMRead and change page elementsdocument.getElementById("x")
EventsReact to user actionsbtn.addEventListener("click", fn)

Where Is JavaScript Used?

JS shows up far beyond simple webpage scripts:

Use caseWhy JavaScript fits
Interactive websitesClicks, forms, animations, client-side validation
Single-page appsReact, Vue, Angular, and similar frameworks
Backend APIsNode.js + Express for JSON services
Mobile & desktopReact Native, Electron, and hybrid apps
ToolingBundlers, linters, and build scripts
Games & graphicsCanvas, WebGL, and browser games

Key Takeaways

  • JavaScript adds behavior to the web—and runs on servers too.
  • Start with console.log, then variables and functions.
  • Not Java—similar names, different languages.
  • Practice: browser Console (F12) or node demo.js.

One line: JavaScript is the web’s programming language—next, try file handling.

Frequently Asked Questions

JavaScript (often abbreviated JS) is a versatile programming language used to create interactive web pages, server APIs with Node.js, mobile apps, games, and more. It runs in every major browser and is one of the core technologies of the web alongside HTML and CSS.
No. Despite similar names, they are unrelated languages. JavaScript was created for browsers; Java targets enterprise and Android. Syntax has some superficial similarities, but they differ in design, typing, and runtime.
Yes for basics. You can write hello world and simple interactivity quickly. Advanced topics—closures, async/await, prototypes, and frameworks—take more practice. Prior programming experience helps, but many beginners start with JavaScript.
Save code as demo.js and run node demo.js if you have Node.js installed. Or open browser DevTools (F12), paste code in the Console, or embed it in an HTML script tag and open the page in Chrome, Firefox, or Edge.
The ECMAScript language specification is an open standard. Major engines—V8 (Chrome/Node), SpiderMonkey (Firefox), JavaScriptCore (Safari)—are open source. You use JavaScript freely without licensing fees.
Practice variables, functions, arrays, and DOM manipulation. Then learn async JavaScript, fetch API, modules, and a framework like React or Vue if you build SPAs. For backends, explore Node.js and Express.

Did you know?

Run JavaScript in the browser with a <script> tag or in Node.js with node file.js. Use console.log() to print output. The language is standardized as ECMAScript; engines like V8 and SpiderMonkey are open source.

Next: File Handling

Learn how JavaScript works with files in the browser and beyond.

File handling →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

13 people found this page helpful