The Language of the Web
JavaScript is the programming language of the internet. Every interactive website you've ever used โ from scrolling through Instagram to searching on Google, from playing browser games to filling out forms โ runs on JavaScript. It's the one language that browsers understand natively, which makes it uniquely powerful.
But JavaScript isn't just for browsers anymore. Today it runs on servers (Node.js), in mobile apps (React Native), on desktop applications (Electron), and even on embedded devices. The language has grown from a simple scripting tool into one of the most versatile programming environments in existence.
Here's the beautiful part: to start writing JavaScript, you don't need to install anything. Your browser has a JavaScript engine built in, ready to execute code right now. Open Chrome, press F12, click "Console," and you're live.
A Brief History
JavaScript was created in just 10 days in 1995 by Brendan Eich at Netscape Communications. The original brief was simple: build a scripting language that non-programmers could use to add interactivity to web pages. The result was called Mocha, then LiveScript, and finally JavaScript โ a name chosen for marketing reasons (Java was the hot language of the time) despite JavaScript having almost nothing in common with Java.
1995
Brendan Eich creates JavaScript in 10 days at Netscape
1997
ECMAScript standard published. JavaScript becomes official
2009
Node.js released. JavaScript runs on servers for the first time
2015
ES6/ES2015 โ the biggest update ever. Modern JS begins here
The language was rushed, and it shows in some quirks that still exist today (we'll learn about them and how to avoid their pitfalls). But despite its origins, JavaScript has evolved dramatically. The ECMAScript committee (TC39) now releases a new version every year, continuously improving the language.
How JavaScript Actually Works
When you load a webpage, your browser downloads HTML, CSS, and JavaScript files. The browser's JavaScript engine compiles and executes the JavaScript code. Modern engines are extremely fast because they use Just-In-Time (JIT) compilation โ they compile JS to machine code on the fly.
Major JavaScript Engines
| Engine | Browser/Runtime | Organization |
|---|---|---|
| V8 | Chrome, Node.js, Edge | |
| SpiderMonkey | Firefox | Mozilla |
| JavaScriptCore | Safari | Apple |
| Hermes | React Native | Meta |
The engine handles:
- Parsing โ reading your code and building an Abstract Syntax Tree (AST)
- Compilation โ converting AST to bytecode, then optimizing to machine code
- Execution โ actually running the compiled code
- Garbage collection โ automatically freeing memory you no longer use
JavaScript vs Other Languages
When you compare JavaScript to other languages, a few things stand out. It's dynamically typed โ variables don't have fixed types. It's interpreted (with JIT compilation). It's single-threaded but handles concurrency through an event loop (more on this in Module 6). And it's everywhere.
// Python-style simplicity
let name = "Alice";
let age = 30;
// Dynamic typing โ same variable, different types
let x = 42; // number
x = "hello"; // now it's a string โ valid in JS!
x = true; // now it's a boolean โ still valid!
// This is very different from Java or C++ where you'd write:
// int x = 42; // type is fixed forever
JavaScript's dynamic typing is powerful but can cause bugs. That's why TypeScript (a typed superset of JS) has become popular. We'll cover it in Module 10.
Your First JavaScript Code
Let's write some real JavaScript right now. Open your browser's console (F12 โ Console tab) and type these examples:
// Your first line of JS
console.log("Hello, JavaScript!");
// Math works as expected
console.log(2 + 2); // 4
console.log(10 * 5); // 50
console.log(100 / 3); // 33.333...
// String concatenation
let firstName = "JavaScript";
let year = 1995;
console.log(firstName + " was born in " + year);
// Modern template literals (backtick syntax)
console.log(`${firstName} was born in ${year}`);
// Check the type of any value
console.log(typeof 42); // "number"
console.log(typeof "hello"); // "string"
console.log(typeof true); // "boolean"
console.log(typeof undefined); // "undefined"
The console.log() function is your best debugging tool. It prints values to the browser's console. You'll use it constantly throughout this course.
Where JavaScript Runs
One of JavaScript's superpowers is its runtime environments. The same language, running in completely different contexts:
Browser (Client-Side)
Manipulates the DOM, handles user events, makes API calls. The original home of JavaScript.
Node.js (Server-Side)
Runs on servers. Build APIs, handle databases, process files. Same language, new power.
React Native (Mobile)
Build iOS and Android apps with JavaScript and React. Native performance, web developer skills.
Electron (Desktop)
Build desktop apps for Windows, Mac, Linux. VS Code, Slack, and Discord are all Electron apps.
// BROWSER: Manipulate the page
document.getElementById("title").textContent = "Hello World!";
document.body.style.backgroundColor = "#08090c";
// NODE.JS: Read a file from the server
const fs = require('fs');
const data = fs.readFileSync('data.json', 'utf8');
console.log(data);
// The language syntax is the same โ the available APIs differ
JavaScript is Everywhere โ The Numbers
JavaScript has been the #1 most used programming language in the Stack Overflow Developer Survey for 11+ consecutive years. Over 95% of websites use JavaScript on the client side. There are over 2 million npm packages (JavaScript libraries). The language is not going anywhere.
GitHub reports JavaScript is the most popular language with millions of repositories. Node.js powers over 30% of websites. React, a JavaScript library, is used by Facebook, Instagram, Airbnb, and thousands of other products.
Learning JavaScript is one of the highest-ROI skills in tech. It opens doors to frontend development, backend development, mobile development, DevOps tooling, and more. A single language, limitless possibilities.
โก Key Takeaways
- JavaScript was created in 1995 and is now the most popular programming language
- It runs natively in all browsers โ no installation needed to start
- Modern JS (ES6+, released 2015) is a completely different experience from old JS
- The same language runs in browsers, servers (Node.js), mobile, and desktop apps
- V8 (Google's engine) powers both Chrome and Node.js
console.log()is your first and most important debugging tool
๐ฏ Practice Exercises
EXERCISE 1
Open your browser console and type: console.log("My name is " + yourName) โ replace yourName with your actual name in quotes.
EXERCISE 2
Use typeof to check the type of: 42, "hello", true, null, undefined, and []. Which results surprise you?
EXERCISE 3 โ CHALLENGE
In the console, calculate how many seconds are in a year. Hint: 60 * 60 * 24 * 365. Store it in a variable and log it with a descriptive message using template literals.