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…
undefined commonly means that no value has yet been assigned, while null is an explicit value often used to represent an intentional absence. They are different values even though both can describe missing information. A declaration without an initializer creates an undefined binding. JavaScript’s typeof null result is a historical special case: it returns "object", not "null". Do not use that result to claim null is a normal object.
let pending;
const selected = null;
console.log(pending);
console.log(selected);
console.log(typeof selected);
console.log("ready");undefined null object ready
The first two values are absent states; the final string is a distinct status message.
let pending;Declare pending with let. The binding may be reassigned later. The expression after = supplies its initial value; = is assignment, not an equality comparison.
const selected = null;Declare selected with const. The binding cannot be reassigned. The expression after = supplies its initial value; = is assignment, not an equality comparison.
console.log(pending);Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
console.log(selected);Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
console.log(typeof selected);typeof reports the type string. Its historical null result is "object"; a quoted "null" value would instead have type "string".
console.log("ready");Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
let pending;
const selected = null;
console.log(pending);
console.log(selected);
console.log(typeof selected);
console.log("waiting");undefined null object waiting
The first two values are absent states; the final string is a distinct status message.
let pending;Declare pending with let. The binding may be reassigned later. The expression after = supplies its initial value; = is assignment, not an equality comparison.
const selected = null;Declare selected with const. The binding cannot be reassigned. The expression after = supplies its initial value; = is assignment, not an equality comparison.
console.log(pending);Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
console.log(selected);Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
console.log(typeof selected);typeof reports the type string. Its historical null result is "object"; a quoted "null" value would instead have type "string".
console.log("waiting");Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
let pending;
const selected = null;
console.log(pending);
console.log(selected);
console.log(typeof selected);
console.log("done");undefined null object done
The first two values are absent states; the final string is a distinct status message.
let pending;Declare pending with let. The binding may be reassigned later. The expression after = supplies its initial value; = is assignment, not an equality comparison.
const selected = null;Declare selected with const. The binding cannot be reassigned. The expression after = supplies its initial value; = is assignment, not an equality comparison.
console.log(pending);Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
console.log(selected);Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
console.log(typeof selected);typeof reports the type string. Its historical null result is "object"; a quoted "null" value would instead have type "string".
console.log("done");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.
let pending;
const selected = "null";
console.log(pending);
console.log(selected);
console.log(typeof selected);
console.log("ready");let pending;
const selected = null;
console.log(pending);
console.log(selected);
console.log(typeof selected);
console.log("ready");When the console prints null, distinguish the actual null value from the string containing those letters.
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.