What is JavaScript?
Understand what JavaScript is, how it relates to ECMAScript, and how it differs from HTML and CSS as the behavior layer of the web.
JavaScript is the programming language of the web — the one piece of the classic HTML/CSS/JavaScript trio that can actually make decisions, repeat actions, and respond to what a user does.
JavaScript, the language
JavaScript is a high-level, dynamically typed programming language originally created in 1995 by Brendan Eich at Netscape, in just ten days, to add interactivity to web pages. Despite the name, it has no real relationship to Java beyond a marketing decision made at the time — they are entirely different languages with different syntax, design, and purpose.
Unlike HTML (which describes structure) and CSS (which describes presentation), JavaScript is a full programming language: it has variables, functions, loops, conditionals, and the ability to read and change almost anything about a running web page in real time.
ECMAScript: the specification behind the language
"JavaScript" is actually an implementation of a language specification called ECMAScript (often abbreviated ES), maintained by a standards body called TC39 under Ecma International. ECMAScript defines the rules of the language itself — its syntax, its types, its built-in objects and methods — while "JavaScript" is the name most engines use for their implementation of that spec.
The specification is versioned and released yearly (ES2015/ES6, ES2016, ES2017, and so on). When you hear developers say "ES6 features" they mean language features introduced in the 2015 edition, such as let/const, arrow functions, classes, and template literals. Nearly every modern browser implements the latest ECMAScript edition within months of its release.
The JavaScript engine and the browser environment
A JavaScript engine is the program that actually reads and executes your JavaScript code. Different browsers use different engines: Chrome and Edge use V8, Firefox uses SpiderMonkey, and Safari uses JavaScriptCore. Node.js also uses V8, which is how JavaScript escaped the browser and became usable on servers.
On its own, the JavaScript language (as defined by ECMAScript) knows nothing about web pages — it has no idea what a button or a <div> is. That capability comes from the browser environment, which layers on extra objects like window, document, and the DOM APIs. The engine executes the language; the environment (browser or Node.js) supplies the extra objects the language uses to actually do useful things.
JavaScript vs HTML vs CSS
The three core web technologies each own a distinct responsibility, and understanding the boundary between them is essential before writing a single line of JavaScript.
• HTML — structure and content: what elements exist on the page • CSS — presentation: how those elements look (color, layout, spacing, fonts) • JavaScript — behavior: what happens when something occurs (a click, a timer, data arriving) and the ability to change HTML/CSS dynamically after the page has loaded
Client-side vs server-side JavaScript
Client-side scripting means JavaScript that runs inside the user's browser, on their own device — this is the original and most common use of JavaScript, powering things like form validation, animations, and dynamic page updates without reloading.
Server-side JavaScript, most commonly via Node.js, means running JavaScript outside the browser entirely, on a server, to build APIs, handle databases, and serve web pages — the same language, but used to power the back end of an application instead of (or in addition to) the front end. This dual capability (one language, both sides of an app) is one of the biggest reasons JavaScript became so dominant.
Code Examples
This is the simplest possible piece of runnable JavaScript: it prints a message to the browser's or Node's console. Expected result: Hello, SampleApp! (printed in the developer console, not on the visible page) console.log(...) is how you output a value so you (the developer) can see it — it does not display anything to the site's visitors.
This demonstrates the kind of thing HTML and CSS simply cannot do on their own: keeping track of changing state (a variable) and updating it every time a function runs. Expected result: Total visits: 1 Total visits: 2 Total visits: 3 This is the essence of "behavior": something happens (the function is called) and JavaScript reacts by changing data and producing a new result.
visits = visits + 1; changes a value in memory — real logic, not just structure or style.
console.log("Hello, SampleApp!");let visits = 0;
function recordVisit() {
visits = visits + 1;
console.log("Total visits: " + visits);
}
recordVisit();
recordVisit();
recordVisit();The three layers of the web
HTML supplies content, CSS supplies appearance, and JavaScript supplies the logic and interactivity that ties them into a working application.
HTML CSS JavaScript
│ │ │
Structure Style Behavior
└──────────┴────────────┘
↓
Web ApplicationImportant Rules
JavaScript is a programming language; HTML and CSS are not — only JavaScript can make decisions, loop, and react to events.
"JavaScript" is the common name; ECMAScript is the formal specification the language implements.
A JavaScript engine (V8, SpiderMonkey, JavaScriptCore, …) executes the language itself; the browser environment adds extra objects like window and document.
The same language runs client-side (in the browser) and server-side (via Node.js) — this is one reason JavaScript is so widely used.
Where this shows up
Virtually every interactive feature on the modern web — dropdown menus, live search suggestions, shopping cart updates, form validation, infinite-scrolling feeds, real-time chat — is powered by JavaScript. Frameworks like React, Vue, and Angular, and back-end tools like Node.js and Express, are all built on top of the same core language covered in this module.
"JavaScript is a scripting version of Java." JavaScript and Java are unrelated languages that happen to share part of a name for historical marketing reasons.
They have different syntax, type systems, runtimes, and use cases — confusing them is one of the most common beginner misconceptions.
"JavaScript only runs in the browser." JavaScript can also run outside the browser, most commonly via the Node.js runtime, to build servers, tools, and scripts.
The language itself is separate from any one environment; browsers and Node.js are two different environments that both embed a JavaScript engine.
[Multiple Choice] What is the relationship between JavaScript and ECMAScript? A. They are completely unrelated languages B. ECMAScript is the specification that JavaScript implements C. JavaScript is the specification and ECMAScript is one implementation of it D. ECMAScript is an older, discontinued version of JavaScript
B. ECMAScript is the specification that JavaScript implements — ECMAScript is the standardized specification (maintained by TC39) that defines the language's rules; JavaScript is the most common name for engines that implement that specification.
[True / False] JavaScript can only run inside a web browser. A. True B. False
B. False — False. JavaScript also runs outside the browser via runtimes like Node.js, which is what allows it to power servers and command-line tools (server-side JavaScript).
In your browser's developer console (or a JavaScript playground), write a line of code that logs your name and the sentence "is learning JavaScript on SampleApp." let name = "Alex"; console.log(name + " is learning JavaScript on SampleApp.");
Use console.log() with a string, combining text using the + operator or a template literal.