Hello, JavaScript! — Your First Program
⏱ 15 min read
JavaScript is the programming language of the web. It runs directly in every modern browser — Chrome, Firefox, Safari, Edge — without any installation. It is the only language that runs natively in browsers, making it essential for web development.
How JavaScript Works:
JavaScript was created in 1995 by Brendan Eich in just 10 days. Today it powers everything from interactive websites to mobile apps, servers, and even desktop applications.
The browser has a built-in JavaScript engine that reads and runs your code:
Chrome/Edge — V8 engine (the fastest, also used by Node.js)
Firefox — SpiderMonkey engine
Safari — JavaScriptCore engine
Three Ways to Run JavaScript:
1. Browser Console — open DevTools with F12, click "Console", type code and press Enter
2. HTML Script Tag — embed JS directly in a web page
3. Node.js — run JS on the command line outside the browser (covered in the Node.js course)
Writing JavaScript in HTML:
<script src="app.js"></script> — link an external JS file (preferred)
<script>/* inline code */</script> — write JS directly inside HTML (avoid for large projects)
Breaking Down Hello World:
console.log(...) — prints to the browser console (DevTools → Console tab)
This is your most important debugging tool. Use it constantly.
alert(...) — shows a popup dialog box in the browser
document.write(...) — writes text directly into the HTML page
Comments in JavaScript:
// This is a single-line comment
/* This is a multi-line comment */
JavaScript ignores all comments — they are notes for humans only.
How JavaScript Works:
JavaScript was created in 1995 by Brendan Eich in just 10 days. Today it powers everything from interactive websites to mobile apps, servers, and even desktop applications.
The browser has a built-in JavaScript engine that reads and runs your code:
Chrome/Edge — V8 engine (the fastest, also used by Node.js)
Firefox — SpiderMonkey engine
Safari — JavaScriptCore engine
Three Ways to Run JavaScript:
1. Browser Console — open DevTools with F12, click "Console", type code and press Enter
2. HTML Script Tag — embed JS directly in a web page
3. Node.js — run JS on the command line outside the browser (covered in the Node.js course)
Writing JavaScript in HTML:
<script src="app.js"></script> — link an external JS file (preferred)
<script>/* inline code */</script> — write JS directly inside HTML (avoid for large projects)
Breaking Down Hello World:
console.log(...) — prints to the browser console (DevTools → Console tab)
This is your most important debugging tool. Use it constantly.
alert(...) — shows a popup dialog box in the browser
document.write(...) — writes text directly into the HTML page
Comments in JavaScript:
// This is a single-line comment
/* This is a multi-line comment */
JavaScript ignores all comments — they are notes for humans only.
Log in to track your progress and earn badges as you complete lessons.
Log In to Track Progress