Skip to content

What is JavaScript?

JavaScript is a high-level, interpreted (or JIT-compiled) programming language that powers the modern web. It’s the only language that runs natively in every web browser.

In the early days of the web (1990s), web pages were static — plain text and images with no interactivity. JavaScript was created to bring life to the web: form validation, animations, interactive maps, real-time updates, and full-blown applications like Google Docs and Figma.

Today, JavaScript is everywhere:

  • Browsers — Every website you visit
  • Servers — Node.js, Deno, Bun
  • Mobile apps — React Native, Ionic
  • Desktop apps — VS Code, Slack, Discord (built with Electron)
  • IoT devices — Smart TVs, robots

“Write once, run anywhere” — Java promised this in the 90s. But JavaScript actually delivered it, just differently: Write once, run in every browser.

When Brendan Eich created JavaScript in 1995, he couldn’t have imagined that 30 years later:

  • NASA uses JavaScript for mission-critical dashboards
  • Netflix streams videos powered by Node.js
  • Tesla uses JavaScript in their infotainment systems
// This simple code runs everywhere — browser, server, phone, even smartwatch
function greetUser(name) {
return `👋 Welcome to the web, ${name}!`;
}
console.log(greetUser("Alice")); // 👋 Welcome to the web, Alice!
flowchart TD
A["💻 You write JavaScript"] --> B["📄 .js file"]
B --> C["⚙️ JavaScript Engine"]
C --> D["🖥️ Machine Code"]
D --> E["✅ Program Executes"]
style A fill:#4f46e5,color:#fff
style E fill:#059669,color:#fff

JavaScript is a multi-paradigm language, which means it supports:

ParadigmWhat it meansExample
Object-OrientedOrganize code using objects and classesclass Car {}
FunctionalUse functions as building blocksarr.map(x => x * 2)
ImperativeWrite step-by-step instructionsif (x > 5) { ... }
Event-DrivenReact to user actionsbutton.onclick = handler
FeatureExplanation
🧵 Single-threadedOne thing at a time (but non-blocking via event loop)
🔄 Dynamic typingVariable types are determined at runtime
🗑 Garbage-collectedAutomatic memory management
🧩 Prototype-basedObjects inherit from other objects (not classes)
📜 Interpreted / JITCompiled just-in-time for performance
// Comments: Single-line or /* multi-line */
// Variables
let name = "Alice"; // can change
const PI = 3.14; // constant
// Data types
42 // number
"hello" // string
true // boolean
null // intentional empty
undefined // not yet assigned
// Functions
function add(a, b) {
return a + b;
}
// Objects & Arrays
const user = { name: "Alice", age: 30 };
const nums = [1, 2, 3, 4, 5];
// Control flow
if (age >= 18) {
console.log("Adult");
} else {
console.log("Minor");
}

JavaScript was created in just 10 days by Brendan Eich in May 1995. It was originally called Mocha, then LiveScript, before being renamed to JavaScript for marketing reasons.

  • Always use === instead of == for comparisons
  • Prefer const over let; never use var in modern code
  • Use meaningful variable names
  • Add semicolons (optional but safe)
  • Enable strict mode: "use strict"

JavaScript is supported by 100% of all web browsers — Chrome, Firefox, Safari, Edge, and even old browsers. It’s the most universally supported programming language in history.

Common question: “Is JavaScript compiled or interpreted?” Answer: Modern JavaScript uses JIT (Just-In-Time) compilation — a hybrid approach. The engine parses → interprets to bytecode → compiles hot code paths to machine code.

  • JavaScript is the language of the web — runs in every browser
  • Multi-paradigm: OOP, functional, event-driven
  • Single-threaded but non-blocking (thanks to the event loop)
  • Fast, flexible, and universally supported

💡 Remember: JavaScript is NOT the same as Java. They just share a name for marketing reasons!