Modern JavaScript (ES6+)
Bring websites to life. Learn core variables, arrow functions, array superpowers, DOM event listeners, asynchronous async/await, and test your code live in our in-browser JS Playground!
JavaScript Curriculum
What is JavaScript? The Robot Analogy
Explain Like I'm 10: Bringing a Mannequin to Life
Imagine a store mannequin standing in a shop window:
• HTML is the plastic body shape and frame.
• CSS is the fancy jacket, hat, and sunglasses on it.
Right now, the mannequin can't move. If you wave at it, nothing happens.
Now, imagine you insert a tiny high-tech computer chip inside the mannequin with gears, sensors, and voice recognition. Suddenly, when someone smiles, the mannequin waves back, counts how many people walked past, and orders more coffee when the pot is empty!
JavaScript is that computer chip. It runs directly inside every web browser on your phone, laptop, or tablet.
Variables: const vs. let
A variable is a labeled storage box in computer memory:
const (Constant - Locked Box)
Use by default for 90% of your variables. The value cannot be reassigned once declared.
let (Reassignable - Open Box)
Use only when you know the value will change over time (like a score counter or loop index).
var keyword in modern code. var has confusing function-scoping and hoisting rules that cause subtle bugs. Always stick to const and let.
Data Types & Strict Equality (===)
JavaScript has primitive types and reference types:
| Data Type | Example | Description |
|---|---|---|
| String | "Free Qube", 'hello' |
Text characters enclosed in quotes. |
| Number | 42, 3.14, -10 |
Integers and floating-point decimals. |
| Boolean | true, false |
Binary truth flags for conditional checks. |
| Null & Undefined | null (empty by design), undefined |
Absence of value. |
| Array | ['Apple', 'Banana', 'Mango'] |
Ordered list of items indexed from 0. |
| Object | { name: 'Bob', age: 28 } |
Key-value dictionary holding complex data. |
Always Use Strict Equality: === vs ==
In JavaScript, == (loose equality) converts types automatically behind your back (e.g., "5" == 5 evaluates to true!). Always use === (strict equality) which compares both value and type without silent coercion.
Functions & ES6 Arrow Syntax
Functions are reusable recipes that take ingredients (arguments) and return a completed dish:
Traditional Function Declaration
Modern Arrow Function (ES6)
Array Superpowers: map, filter & reduce
In modern JavaScript, you almost never need old-fashioned for loops to transform lists of data:
DOM Manipulation & Interactive Event Listeners
The DOM (Document Object Model) is the tree representation of your HTML page in memory. JavaScript can read and modify elements in real time without refreshing the page:
Asynchronous JavaScript: async / await & Fetch
When fetching data from a cloud server or external API, it takes a fraction of a second. Instead of freezing the user's browser, JavaScript uses non-blocking Promises and clean async / await syntax:
Put Your Knowledge to Work Right Now
Don't just read about code—write it! Free Qube provides a live, interactive JavaScript Playground & Runner. Write code in the left editor, click "Run Code", and inspect variables, errors, and console logs instantly on the right side screen.