Introduction to JavaScript
Why this matters: JavaScript is the only language that runs in every web browser on Earth. If you have ever clicked a button on a website and something happened, you have used JavaScript. Learning JavaScript is the fastest path into web development, and once you have it, the same skills carry you into mobile apps (React Native), servers (Node.js) and even desktop apps (Electron).
The short version
JavaScript is a high-level, interpreted programming language. It runs inside every web browser, on servers via Node.js and inside mobile and desktop apps. It is forgiving, fast to start with, and the most-used programming language in the world according to every annual developer survey.
A short history (with a name that misleads everyone)
JavaScript has one of the wildest origin stories in programming.
In May 1995, the engineer Brendan Eich was hired by Netscape to add a scripting language to their web browser. He was given ten days to ship a prototype. The first version of JavaScript was written in that ten-day sprint. Almost everything we now consider weird about JavaScript (type coercion, implicit conversions, the existence of null and undefined) traces back to design decisions made in that fortnight.
The language was originally called Mocha, then LiveScript. Days before launch, Netscape renamed it JavaScript. Why? Java was the hottest language of 1995 and the name "JavaScript" was thought to help with marketing. It worked, but it has confused beginners ever since.
JavaScript and Java are not related. They are different languages, by different teams, for different purposes. Saying "I know JavaScript" is not the same as "I know Java", just like saying "I drive a car" is not the same as "I drive a carpet". Important to internalise this on day one.
In 1997, JavaScript was standardised under the name ECMAScript (the spec that everyone implements). The big modernising release was ES2015 (also called ES6), which introduced let, const, arrow functions, template literals and the class keyword. Almost everything you will recognise as "modern JavaScript" arrived in that release. The language now gets a new yearly release (ES2016, ES2017 and so on).
In 2009, an engineer named Ryan Dahl took the V8 JavaScript engine from Google Chrome and used it to run JavaScript on servers. He called it Node.js. That single project moved JavaScript out of the browser and turned it into a full-stack language overnight.
What JavaScript can do today
- Run in every browser: Chrome, Firefox, Safari, Edge. Same code, every machine.
- Build web applications: Gmail, Facebook, Twitter, Notion and Figma are all built on JavaScript and React or similar.
- Run on servers: Node.js powers backends at Netflix, Uber, LinkedIn and many SA startups.
- Build mobile apps: React Native lets one JavaScript codebase ship to both iOS and Android.
- Build desktop apps: Electron (the thing VS Code is built on) wraps a JavaScript app in a desktop window. Slack, Discord and Spotify desktop are all Electron apps.
- Power browser games: HTML5 plus JavaScript games run on every device with a browser.
Your first JavaScript
console.log("Sawubona! Hello from JavaScript!");
console.log("Welcome to HardCoded");
These two lines print messages to the console. You can run them right now: open Chrome, press F12 to open Developer Tools, click the Console tab, paste the code in and press Enter. You have just run JavaScript in a real browser.
Where you see JavaScript in South Africa
JavaScript is the most in-demand programming skill for SA web work:
- Front-end developers: every modern SA web app uses React, Vue or Angular, all of which are JavaScript
- Full-stack developers: Node.js on the backend is standard at most SA startups
- Mobile: React Native teams at many SA fintechs
- Remote work: JavaScript is the most common skill for SA developers working remotely for international companies
Career prospects
Indicative monthly salaries for JavaScript developers in South Africa:
- Entry-level (junior front-end): R20,000 to R32,000
- Mid-level: R40,000 to R65,000
- Senior: R65,000 to R105,000+
- Staff or lead: R85,000 to R140,000+
Remote roles for international companies often pay significantly more in USD or GBP.
Tools you need
You do not need to install anything to start. JavaScript runs inside your browser already.
For more serious work:
- A modern browser: Chrome or Firefox, both have excellent developer tools
- A code editor: VS Code is the industry default and is free
- Node.js (later): not needed for the first few lessons, but you will install it when we cover backend topics