An Introduction to JavaScript · learncode.live

An Introduction to JavaScript

JavaScript (often abbreviated as JS) is a high-level, interpreted programming language that makes web pages interactive. Alongside HTML and CSS, it is one of the three core technologies of the World Wide Web.

What is JavaScript?

JavaScript was created by Brendan Eich in 1995 while working at Netscape. Originally called Mocha, then LiveScript, it was renamed to JavaScript as a marketing move during the rise of Java.

Today, JavaScript runs everywhere - browsers, servers (Node.js), mobile apps, desktop applications, and even IoT devices.

Here’s a simple taste of JavaScript:

Demo: Your First JavaScript
HTML
<p id='demo'></p>
JavaScript
document.getElementById('demo').textContent = 'Hello, JavaScript!';
Live Output Window

What can JavaScript do?

  • DOM Manipulation - change HTML and CSS on the fly
  • Event Handling - respond to clicks, keystrokes, form submissions
  • API Calls - fetch data from servers
  • Animations - create smooth visual effects
  • Full-stack development - build servers with Node.js, Deno, Bun

What CAN’T JavaScript do?

  • File system access (in the browser) - browsers sandbox JS for security
  • Raw network access - no low-level socket control without APIs
  • Multithreading - JavaScript is single-threaded (but has Web Workers)

Manuals and Specifications

When learning JavaScript, these resources are essential:

ResourceURLPurpose
MDN Web Docsdeveloper.mozilla.orgThe definitive JS reference
ECMAScript Spectc39.es/ecma262The official language specification
JavaScript Infojavascript.infoModern tutorial (what this series is based on)
Can I Usecaniuse.comCheck browser compatibility

The language is formally called ECMAScript (ES). The version matters:

VersionYearKey Features
ES52009Strict mode, JSON, Array methods
ES6/ES20152015let/const, arrow functions, classes, modules, Promises
ES20162016** operator, Array.includes
ES20172017async/await, Object.values/entries
ES20182018Rest/spread for objects, Promise.finally
ES20192019Array.flat, Object.fromEntries
ES20202020Optional chaining, nullish coalescing, BigInt
ES20212021String.replaceAll, Promise.any, WeakRef
ES20222022Class fields, Array.at, Object.hasOwn
ES20232023Array.findLast, Hashbang Grammar

Code Editors

You need a good editor to write JavaScript. Here are popular choices:

EditorBest ForPlatform
VS CodeEverything - most popularWindows, Mac, Linux
WebStormProfessional JS developmentWindows, Mac, Linux
Sublime TextLightweight, fastWindows, Mac, Linux
Vim / NeovimTerminal-based, keyboard-drivenWindows, Mac, Linux

For this tutorial series, VS Code is recommended. Key extensions:

  • ESLint - catches errors as you type
  • Prettier - auto-formats your code
  • JavaScript (ES6) code snippets - boosts productivity

Developer Console

Every browser has a Developer Console where you can experiment with JavaScript in real-time.

How to open it

BrowserShortcut
Chrome / EdgeCtrl + Shift + J (Win/Linux), Cmd + Option + J (Mac)
FirefoxCtrl + Shift + K (Win/Linux), Cmd + Option + K (Mac)
SafariCmd + Option + C (Mac)

Using the Console

The console is a REPL (Read-Eval-Print-Loop). You type JavaScript, it runs immediately:

console.log("Hello from the console!");
// → Hello from the console!

2 + 2
// → 4

typeof "hello"
// → "string"

Try pasting this in your console:

console.log('This appears in the console tab!');
console.warn('This is a warning');
console.error('This is an error');
console.table([{name: 'Alice', age: 30}, {name: 'Bob', age: 25}]);

Pro tip: Use console.log() frequently while learning - it’s your best debugging friend.

Console Methods

MethodPurpose
console.log()General logging
console.warn()Warning message (yellow)
console.error()Error message (red)
console.table()Display arrays/objects as a table
console.group()Group related logs together
console.time() / console.timeEnd()Measure execution time
console.count()Count how many times something runs
console.time("loop");
for (let i = 0; i < 1000000; i++) {}
console.timeEnd("loop");
// → loop: 2.45ms
Courses