Skip to main content

Beginner-Friendly Topic

Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!

Lesson 1 of 11

What is JavaScript & How It Works

JavaScript is the programming language of the web. It makes websites interactive - buttons, forms, animations, and dynamic content. JavaScript runs directly in the browser and on servers (Node.js), making it the most versatile language for web development.

15 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

What is JavaScript?

JavaScript (JS) is a lightweight, interpreted programming language created in 1995. While HTML provides structure and CSS provides styling, JavaScript adds interactivity and logic. Every modern website uses JavaScript. It runs in the browser without any installation - open DevTools (F12) and start coding immediately.

Diagram
Loading diagramโ€ฆ

What is JavaScript & How It Works in JavaScript

What JavaScript Can Do

  • Change HTML content dynamically - show/hide elements, update text, modify styles
  • Respond to user actions - clicks, keyboard input, mouse movements, form submissions
  • Validate form inputs before sending to the server - instant feedback without page reload
  • Fetch data from APIs - load content, display live data, communicate with servers
  • Create animations and visual effects - smooth transitions, scroll effects, interactive UI
  • Build complete web applications - React, Vue, Angular are all JavaScript frameworks
  • Run on servers with Node.js - one language for both frontend and backend

Your First JavaScript

Your First JavaScript
// JavaScript runs in the browser console (press F12)
console.log("Hello, World!");
console.log("Welcome to JavaScript!");

// JavaScript can do math
console.log(10 + 5);    // 15
console.log(100 * 2);   // 200

// JavaScript can work with text
console.log("My name is " + "Alice");

// JavaScript can make decisions
if (10 > 5) {
  console.log("10 is greater than 5!");
}

Try It Yourself: Hello World

Try It Yourself: Hello WorldJavaScript
JavaScript
โœ“ Valid
JavaScript|14 lines|โœ“ Valid syntax
UTF-8

Tip

Tip

Open your browser console right now (F12 โ†’ Console tab) and type code directly - it's the fastest way to practice. Every modern browser has a built-in JavaScript playground with zero setup.

Common Mistake

Warning

Don't confuse JavaScript with Java - they are completely different languages with different use cases. JavaScript runs in browsers and Node.js; Java is a compiled language for enterprise and Android apps.

Practice Task

Note

Open DevTools (F12 โ†’ Console) and try these exercises: (1) Type console.log('Your Name') and press Enter. (2) Calculate your birth year: console.log(2026 - yourAge). (3) Combine text: console.log('Hello ' + 'World').

Quick Quiz

Key Takeaways

  • JavaScript is the programming language of the web.
  • Change HTML content dynamically - show/hide elements, update text, modify styles
  • Respond to user actions - clicks, keyboard input, mouse movements, form submissions
  • Validate form inputs before sending to the server - instant feedback without page reload

Finished this lesson?

0 of 11 in Module 1
Sign in to save progress

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/11 done