Ready. Start with one instruction.
Loading the learning workspace…
FROM YOUR FIRST INSTRUCTION TO A WORKING APPLICATION
Learn JavaScript from scratch through small working examples, visual experiments and complete projects. No account or AI key required.
Predict → Experiment → Build → Test → Explain
Ready. Start with one instruction.
Loading the learning workspace…
An ES module is a file with an explicit boundary. math.js exports the named double function; the entry file imports that binding from a relative path. The import name must match an exported name, and the supporting file must be served at the expected URL. Browsers normally load module scripts over HTTP(S), with type="module". This practice runner bundles its small, prepared named-import example for isolated execution; it does not install packages or support every module feature. Compare the two visible files before running.
import { double } from "./math.js";
console.log(double(4));8
The named import refers to double from math.js. Its return is twice the literal argument.
import { double } from "./math.js";Import the named export from the visible supporting file. A missing or mismatched path is a loading error.
console.log(double(4));Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
import { double } from "./math.js";
console.log(double(0));0
The named import refers to double from math.js. Its return is twice the literal argument.
import { double } from "./math.js";Import the named export from the visible supporting file. A missing or mismatched path is a loading error.
console.log(double(0));Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
import { double } from "./math.js";
console.log(double(-2));-4
The named import refers to double from math.js. Its return is twice the literal argument.
import { double } from "./math.js";Import the named export from the visible supporting file. A missing or mismatched path is a loading error.
console.log(double(-2));Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
Repair the intentionally changed operation so the example produces the exact expected result. Then try the extension without copying the answer.
import { triple } from "./math.js";
console.log(double(4));import { double } from "./math.js";
console.log(double(4));Define and call a square helper.
Which operation changed the result, why did it work, and what would you test next?
Use a different value that could expose a boundary or mistake. Predict the result first, run it, and explain how the concept would help in a small real application.
Related: Previous lesson Next lesson
100 lessons across 20 modules, covering variables, operators, strings, conditions, loops, functions, scope, arrays, objects, DOM, events, state, testing, asynchronous JavaScript and application development.