🌱BeginnerJavaScript Fundamentals

Introduction to JavaScript

What JavaScript is, where it runs, and why it matters for web development.

Overview

JavaScript is the programming language of the web. Originally built in 1995 to add interactivity to web pages, it has grown into one of the most widely used languages in the world running in every browser, on servers via Node.js, in mobile apps, desktop tools, and even IoT devices. Unlike most languages that must be compiled before running, JavaScript is interpreted at runtime. Every browser ships with a built-in JavaScript engine (Chrome uses V8, Firefox uses SpiderMonkey) that reads and executes your code directly. This means you can open a browser console right now and run JavaScript instantly. JavaScript is a dynamically typed language you don't declare the type of a variable upfront; the engine figures it out at runtime. It's also prototype-based, event-driven, and supports both functional and object-oriented programming styles. These characteristics make it unusually flexible but also a source of some notorious quirks that every JS developer eventually learns to navigate.

Key Points

  • •JavaScript runs in every web browser and on servers via Node.js no install required to start
  • •It is interpreted (not compiled): code runs as-is without a build step in the browser
  • •Dynamically typed: variables can hold any value and types are checked at runtime
  • •Single-threaded with a non-blocking event loop handles async tasks without freezing the page
  • •ECMAScript (ES) is the specification; major versions ES5, ES6/ES2015, and yearly releases (ES2024) add new features
  • •The browser console (F12 → Console tab) is your best friend for learning and debugging

Examples

Your first JavaScript log a message to the console

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

console.log() is the most common way to print output while learning and debugging.

JavaScript can do arithmetic, string manipulation, and more

console.log(2 + 2);           // 4
console.log("Hello" + " " + "World"); // Hello World
console.log(typeof 42);   // "number"
console.log(typeof "hi"); // "string"

A quick look at modern JavaScript (ES6+)

const greet = (name) => `Hello, ${name}!`;
console.log(greet("Alice")); // Hello, Alice!

Arrow functions and template literals are ES6 features you will use constantly.

Common Mistakes

  • Confusing JavaScript with Java they are completely unrelated languages
  • Forgetting that browser JS and Node.js have different built-in APIs (e.g. window only exists in browsers)
  • Case sensitivity: `console.log` works, `Console.log` or `console.Log` throw an error

Note

Open your browser DevTools (F12) and click the Console tab. You can run any JavaScript code there instantly no editor or setup needed.

Exercises

Write JavaScript code to solve each exercise. Run it and check your output.

Loading editor…

Completed: 0 / 5 exercises

Knowledge Check

Question 1 of 4

Where does JavaScript code run?