JavaScript Programming · Practice by type
JavaScript Programming MCQ Questions and Answers
Multiple-choice questions on JavaScript Programming concepts and common errors, topic by topic, each with the answer and a clear explanation.
- 735 questions
- 25 topics
- Answers checked on a real compiler
JavaScript Basics 30 questions
- Which engine runs JavaScript in Chrome and Node.js? Easy
- Which statement about JavaScript is true? Easy
- JavaScript and ECMAScript Easy
- defer vs async Medium
- Which name is a valid identifier? Easy
- Which word is reserved? Medium
- Nested block comments Medium
- Automatic Semicolon Insertion Medium
- What does "use strict" do? Easy
- Code that is always strict Hard
- typeof a function Easy
- Return value of console.log Medium
- Template literal syntax Easy
- document in Node.js Medium
- When is a SyntaxError reported? Hard
- Error: unexpected end of input Easy
- Error: apostrophe inside a single-quoted string Easy
- Error: identifier has already been declared Medium
- Error: missing initializer in const Medium
- Error: duplicate parameter names in strict mode Hard
- Error: commenting out code that has a comment Medium
- Error: console.Log Easy
- Error: variable name with the wrong case Easy
- Error: a line that starts with ( Hard
- Error: a line that starts with [ Hard
- Error: undeclared variable in strict mode Medium
- Error: assignment to a const Medium
- Bug: numbers stored as strings Easy
- Bug: = inside an if condition Medium
- Bug: returning an object on the next line Medium
Variables: var, let and const 30 questions
- Scope of a var variable Easy
- Scope of let and const Easy
- Which keyword allows redeclaration? Easy
- What does const guarantee? Medium
- The temporal dead zone Medium
- Which statement about hoisting is correct? Medium
- Top-level declarations and window Hard
- Which declaration must be initialised? Easy
- Object.freeze and nested objects Hard
- Recommended declaration style Easy
- typeof on a variable in the TDZ Hard
- let in a for loop Medium
- Assigning without a declaration Medium
- const as a classic for-loop counter Hard
- Shadowing a let with a var Hard
- Error: let and var with the same name Medium
- Error: var inside a block shadowing a let Hard
- Error: the same let in two switch cases Hard
- Error: let as the body of an if without braces Hard
- Error: using a let before its declaration Easy
- Error: an inner let shadows the outer variable too early Hard
- Error: a const used as a running total Medium
- Error: const as a for-loop counter Medium
- Error: using a block-scoped const outside its block Easy
- Error: changing a frozen object in strict mode Hard
- Error: typeof on a let before its declaration Hard
- Bug: every button reports the same index Medium
- Bug: the total stays 0 Easy
- Bug: nested loops without let Hard
- Bug: the global discount is ignored Hard
Data Types 30 questions
- How many primitive types? Easy
- Which is not a primitive? Easy
- Checking for null Medium
- The type of NaN Easy
- Number.MAX_SAFE_INTEGER Medium
- Which value is truthy? Easy
- Meaning of null and undefined Easy
- Detecting an array Medium
- isNaN vs Number.isNaN Hard
- Mixing BigInt and Number Medium
- Strings are immutable Medium
- Comparing two objects Medium
- Symbol uniqueness Medium
- How numbers are stored Easy
- How does "abc".length work? Hard
- Error: a BigInt with a decimal point Medium
- Error: misplaced numeric separator Hard
- Error: a variable name that starts with a digit Easy
- Error: calling a method on a number literal Medium
- Error: adding a Number to a BigInt Medium
- Error: reading a property of null Easy
- Error: a missing nested object Easy
- Error: joining a symbol to a string Hard
- Error: a string method on a number Easy
- Error: BigInt() of a decimal Hard
- Error: JSON.stringify with a BigInt Hard
- Bug: empty input accepted as a number Hard
- Bug: comparing a decimal sum exactly Medium
- Bug: typeof-based type detection Medium
- Bug: changing the "copy" changes the original Easy
Operators 30 questions
- == vs === Easy
- The % operator Easy
- Associativity of ** Medium
- What does && return? Medium
- ?? vs || Medium
- Optional chaining Easy
- Postfix vs prefix increment Easy
- null >= 0 vs null == 0 Hard
- The in operator Medium
- The conditional (ternary) operator Easy
- Mixing ?? with || Hard
- Unary plus Easy
- delete on an array element Hard
- How instanceof decides Medium
- Object.is vs === Hard
- Error: ?? combined with || Hard
- Error: incrementing a literal Medium
- Error: a negative number raised to a power Hard
- Error: assigning to an expression Medium
- Error: assigning through optional chaining Hard
- Error: the in operator on a string Hard
- Error: instanceof with an object on the right Hard
- Error: unary plus on a BigInt Hard
- Error: optional chaining in the wrong place Medium
- Bug: a volume of 0 is ignored Medium
- Bug: adding numbers stored as strings Easy
- Bug: the average is too high Easy
- Bug: every temperature is "comfortable" Medium
- Bug: a missing score is graded "Fail" Medium
- Bug: an invalid number is not detected Easy
Conditional Statements 30 questions
- How switch compares values Easy
- A case without break Easy
- Where can default go? Medium
- How many branches run? Easy
- if ("false") Easy
- Which if does the else belong to? Medium
- Why write switch (true)? Medium
- Ternary vs if Easy
- A let declared inside an if Easy
- Evaluation of case expressions Hard
- What is a guard clause? Medium
- Lookup tables Medium
- if (x = 5) Medium
- Optional chaining in a condition Easy
- case NaN Hard
- Error: unexpected token else Medium
- Error: condition without parentheses Easy
- Error: elif instead of else if Easy
- Error: two default clauses Medium
- Error: a case without a colon Easy
- Error: checking a property of a missing object Easy
- Error: a condition on an undeclared variable Easy
- Error: calling a missing method in a condition Medium
- Error: switch on a property of null Medium
- Error: using a block variable before it is declared Medium
- Bug: every size costs the same Easy
- Bug: big orders get the small discount Easy
- Bug: zero stock reported as unknown Medium
- Bug: every menu choice is invalid Medium
- Bug: logged-in users are asked to log in Hard
Loops 30 questions
- Which loop always runs at least once? Easy
- What does for…in give you? Easy
- for…of on a plain object Easy
- break inside forEach Medium
- What does continue do? Easy
- Labelled break Medium
- An infinite for loop Easy
- for…in on arrays Medium
- Order of object keys Hard
- Index and value in for…of Easy
- let in a for loop head Medium
- return inside forEach Medium
- forEach and holes Hard
- Which method stops at the first match? Medium
- Iterating a string with an emoji Hard
- Error: break inside forEach Medium
- Error: commas instead of semicolons in for Easy
- Error: break to a label that does not exist Medium
- Error: continue outside a loop Medium
- Error: do without while Easy
- Error: for…of over a plain object Easy
- Error: for…of over null Medium
- Error: forEach on an object Easy
- Error: reading one element past the end Medium
- Error: for…of over a number Medium
- Bug: the total is NaN Easy
- Bug: summing an array with for…in Medium
- Bug: some even numbers survive Medium
- Bug: a search function always returns undefined Medium
- Bug: the countdown never runs Easy
Functions 30 questions
- Which function can be called before its definition? Easy
- When does a default parameter apply? Medium
- Where must the rest parameter go? Easy
- arguments in arrow functions Medium
- A function without return Easy
- First-class functions Easy
- Higher-order functions Easy
- Purpose of an IIFE Medium
- fn.length with defaults Hard
- How arguments are passed Medium
- Missing and extra arguments Easy
- Named function expressions Hard
- Pure functions Medium
- What is a callback? Easy
- When are defaults evaluated? Hard
- Error: rest parameter before another parameter Easy
- Error: duplicate parameter names with a default Hard
- Error: an arrow function returning an object Medium
- Error: a function declaration without a name Medium
- Error: "use strict" in a function with defaults Hard
- Error: calling a var function expression too early Medium
- Error: calling a const arrow function too early Medium
- Error: calling what a factory forgot to return Medium
- Error: recursion without a base case Medium
- Error: a required argument is missing Easy
- Bug: the area is undefined Easy
- Bug: a 0% discount becomes 10% Medium
- Bug: printing the function instead of its result Easy
- Bug: a recursive sum returns undefined Medium
- Bug: a "copy" function changes the original Hard
Scope and Hoisting 30 questions
- What does lexical scope mean? Medium
- Direction of the scope chain Easy
- Kinds of scope Easy
- What is hoisted completely? Easy
- Are classes hoisted? Medium
- The creation phase Hard
- A name found in no scope Easy
- Who can see whose variables? Easy
- var at the top of an ES module Hard
- What is a closure? Medium
- Scope vs this Hard
- globalThis Medium
- Reaching a shadowed variable Medium
- Hoisting of a var function expression Medium
- Avoiding globals Easy
- Error: let with the same name as a parameter Medium
- Error: a class declared twice Medium
- Error: a const and a function with the same name Hard
- Error: redeclaring the catch parameter Hard
- Error: using another function's local variable Easy
- Error: creating an object before its class Medium
- Error: a function reads a let that is not initialised yet Hard
- Error: using a let loop counter after the loop Easy
- Error: a block reads its own variable too early Medium
- Error: calling a nested helper from outside Easy
- Bug: the price shows the wrong currency Medium
- Bug: a helper resets the app counter Medium
- Bug: a saved rule uses a later discount Hard
- Bug: a later function silently replaces the first Hard
- Bug: the minimum salary is ignored Medium
Arrays 30 questions
- What does new Array(3) create? Medium
- What does push return? Easy
- slice vs splice Easy
- How does sort() compare by default? Medium
- Reading the last element Easy
- Setting length Medium
- typeof an array Easy
- Finding NaN Hard
- Array.of vs the Array constructor Medium
- Comparing arrays Easy
- fill with an object Hard
- Which method changes the array? Medium
- push vs unshift on large arrays Hard
- toSorted() Medium
- What can Array.from convert? Medium
- Error: missing comma in an array literal Easy
- Error: destructuring declaration without a value Medium
- Error: rest element before another element Medium
- Error: a trailing comma after the rest element Hard
- Error: an array with a negative length Medium
- Error: pushing to a property that is not an array Easy
- Error: reassigning a const array Easy
- Error: an array method on a string Medium
- Error: destructuring undefined Medium
- Error: pushing to a frozen array Hard
- Bug: the wrong student is ranked first Easy
- Bug: marking one seat books a whole column Hard
- Bug: the backup changes too Easy
- Bug: identical answers marked wrong Medium
- Bug: the first role is not recognised Medium
Strings 30 questions
- Are strings mutable? Easy
- Which quotes interpolate? Easy
- Why is an emoji's length 2? Hard
- charAt vs [] out of range Medium
- slice vs substring with negative numbers Medium
- Why is "a" < "B" false? Medium
- What is localeCompare for? Medium
- String(x) vs x.toString() Medium
- new String("hi") Medium
- What can go inside ${ }? Easy
- Tagged templates Hard
- String.raw Hard
- Building a long string Medium
- includes vs indexOf Easy
- Escape for a new line Easy
- Error: mismatched quotes Easy
- Error: a line break inside a quoted string Easy
- Error: an unclosed ${ placeholder Medium
- Error: an invalid Unicode escape Hard
- Error: an octal escape in strict mode Hard
- Error: reversing a string directly Easy
- Error: trimming a missing value Easy
- Error: repeat with a negative count Medium
- Error: an invalid code point Hard
- Error: an unknown normalisation form Hard
- Bug: an update is not offered Medium
- Bug: "yes" is not accepted Easy
- Bug: a correct username is rejected Easy
- Bug: the replacement does not appear Easy
- Bug: the character counter is too high Hard
Objects 30 questions
- Reading a property whose name is in a variable Easy
- Computed property names Easy
- Number keys Medium
- What does delete return? Medium
- in vs Object.hasOwn Medium
- freeze vs seal Medium
- How deep does spread copy? Medium
- this in a method call Easy
- Comparing two objects Easy
- What JSON.stringify leaves out Medium
- Getters Medium
- Object.create(null) Hard
- What Object.entries returns Easy
- Defaults of Object.defineProperty Hard
- Object.assign and its target Medium
- Error: missing comma between properties Easy
- Error: mixing method and arrow syntax Medium
- Error: a getter with a parameter Hard
- Error: a setter without a parameter Hard
- Error: a hyphen in an unquoted key Easy
- Error: Object.keys on null Medium
- Error: a detached method in strict mode Hard
- Error: redefining a locked property Hard
- Error: JSON with single quotes Medium
- Error: stringifying a circular object Hard
- Bug: every lookup returns undefined Easy
- Bug: editing a draft changes the saved profile Medium
- Bug: an item with zero stock is "not in the catalogue" Medium
- Bug: the total contains text Hard
- Bug: a default setting disappears Medium
Array Methods 30 questions
- What does map return? Easy
- What does filter keep? Easy
- reduce on an empty array Medium
- What does forEach return? Easy
- find vs filter Easy
- every on an empty array Hard
- map(parseInt) Hard
- Default depth of flat Medium
- What flatMap does Medium
- When nothing matches Easy
- Which method changes the array? Medium
- Arguments passed to callbacks Easy
- The accumulator in reduce Easy
- findLast Medium
- Is sort stable? Hard
- Error: returning an object from a map callback Medium
- Error: unclosed call Easy
- Error: continue inside a callback Medium
- Error: await inside a normal callback Hard
- Error: reduce on an empty cart Medium
- Error: mapping a missing API field Easy
- Error: passing a string instead of a function Medium
- Error: using the result of find without a check Medium
- Error: sorting when a name is missing Hard
- Error: map on a Set Medium
- Bug: quantities become NaN Medium
- Bug: the discounted prices are undefined Easy
- Bug: the order total is a strange string Hard
- Bug: admin panel shown to everyone Medium
- Bug: names are not sorted Medium
String Methods 30 questions
- replace with a string pattern Easy
- replaceAll with a regex Hard
- padStart Easy
- What does trim remove? Easy
- The limit argument of split Medium
- match with the g flag Medium
- matchAll Hard
- search vs indexOf Medium
- Natural sorting Medium
- Why normalize? Hard
- $1 in a replacement Medium
- The position argument of includes Medium
- Regex flags Easy
- test() with a global regex Hard
- Which method returns a boolean? Easy
- Error: an unterminated regex literal Medium
- Error: an unclosed group Medium
- Error: an unknown regex flag Hard
- Error: two groups with the same name Hard
- Error: replaceAll with a non-global regex Hard
- Error: matchAll without g Hard
- Error: a RegExp built from raw user input Medium
- Error: indexing a null match Medium
- Error: padStart on a number Easy
- Error: splitting a missing value Easy
- Bug: only one space is replaced Easy
- Bug: the course is not found Easy
- Bug: "1+1" is never replaced Hard
- Bug: chapter 10 comes before chapter 2 Medium
- Bug: names with double spaces do not match Medium
ES6 Features 30 questions
- The official name of ES6 Easy
- typeof a class Easy
- super() in a derived constructor Medium
- Private fields Medium
- Static members Easy
- Map keys Medium
- Set and objects Medium
- WeakMap Hard
- What makes an object iterable? Medium
- Generators Medium
- yield vs return in a generator Hard
- Default and named exports Medium
- Properties of ES modules Medium
- Symbol keys Medium
- Using a class Hard
- Error: the function keyword inside a class Easy
- Error: super() in a class that extends nothing Medium
- Error: reading a private field from outside Medium
- Error: yield in a normal function Medium
- Error: two constructors Medium
- Error: import in a classic script Hard
- Error: calling a class like a function Easy
- Error: this before super() Medium
- Error: a primitive WeakMap key Hard
- Error: new Symbol() Medium
- Error: spreading an object into an array Medium
- Bug: Map entries go missing Medium
- Bug: duplicate users survive a Set Medium
- Bug: the count is 0 Hard
- Bug: a copied object loses its methods Hard
Arrow Functions 30 questions
- When is the value returned automatically? Easy
- Returning an object literal Easy
- Where does an arrow get this? Medium
- arguments inside an arrow Medium
- new with an arrow function Medium
- An arrow as an object method Medium
- call, apply and bind with arrows Hard
- Are arrow functions hoisted? Medium
- A good place for an arrow function Easy
- A bad place for an arrow function Medium
- The prototype property Hard
- Parentheses around one parameter Easy
- A line break before => Hard
- Class-field arrow functions Hard
- Arrow generators Hard
- Error: a line break before => Hard
- Error: two parameters without parentheses Easy
- Error: a generator arrow Hard
- Error: duplicate parameters in an arrow Hard
- Error: return in an expression body Easy
- Error: an arrow used as a constructor Medium
- Error: an arrow method that uses this Medium
- Error: an arrow on a prototype Hard
- Error: calling a const arrow too early Easy
- Error: a regular callback inside a class method Medium
- Bug: every price is undefined Easy
- Bug: the full name is "undefined undefined" Medium
- Bug: call() does not set the name Hard
- Bug: mapping ids to objects gives undefined Medium
- Bug: arrows do not fix the var loop Medium
Destructuring 30 questions
- How patterns match values Easy
- When does a default apply? Easy
- Renaming syntax Easy
- Rename and default together Medium
- Where can the rest element go? Easy
- Destructuring null Medium
- Destructuring into existing variables Hard
- Skipping items Easy
- What object rest collects Medium
- When defaults are evaluated Hard
- Variables from a nested pattern Hard
- Why "= {}" after a parameter pattern? Medium
- Destructuring iterables Medium
- Swapping variables Easy
- An array pattern on an object Medium
- Error: object rest before another property Easy
- Error: destructuring assignment without parentheses Hard
- Error: a destructuring declaration without a value Medium
- Error: a default on the rest element Hard
- Error: a number as a destructuring target Medium
- Error: destructuring a null result Easy
- Error: calling a destructured function without an argument Medium
- Error: an array pattern on a plain object Medium
- Error: a nested pattern over a missing object Medium
- Error: a default that uses a later variable Hard
- Error: a swap without semicolons Hard
- Bug: the renamed variable is undefined Medium
- Bug: the default avatar is not used Easy
- Bug: the setting does not change Medium
- Bug: the sanitised copy changes the original Hard
Spread and Rest Operators 30 questions
- Spread or rest? Easy
- How deep is an array spread copy? Medium
- Which value wins? Easy
- Spreading null Hard
- Rules for rest parameters Easy
- Rest parameters vs arguments Medium
- Math.max with an array Easy
- Spreading a string Easy
- Conditional spread Medium
- What object spread copies Hard
- Spread vs Object.assign Hard
- Spreading an object into an array Medium
- undefined in a merge Medium
- Object rest in destructuring Easy
- Spreading a huge array into a call Hard
- Error: a trailing comma after a rest parameter Hard
- Error: two rest parameters Easy
- Error: spread on its own Easy
- Error: a rest parameter without parentheses Medium
- Error: a pattern after object rest Hard
- Error: spreading an object into an array Easy
- Error: spreading null into an array Medium
- Error: spreading undefined into a call Easy
- Error: spreading millions of numbers into Math.max Hard
- Error: object rest from null Medium
- Bug: the old state changes too Medium
- Bug: an empty form field erases the default Medium
- Bug: the Set has only one item Hard
- Bug: a new tag becomes letters Medium
- Bug: user choices are ignored Easy
Closures 30 questions
- What is a closure? Easy
- When is a closure created? Medium
- What does a closure capture? Medium
- Two calls of a factory Easy
- Closures from the same call Medium
- Fixing the loop closure problem Easy
- Privacy with closures Easy
- Closures and memory Hard
- The module pattern Medium
- When can captured data be freed? Hard
- Stale closures Hard
- Closures and this Hard
- Memoization Easy
- IIFE in a var loop Medium
- A counter's third call Easy
- Error: an unclosed factory Easy
- Error: ++ in a parameter list Medium
- Error: an expression inside an object literal Medium
- Error: an IIFE without parentheses Medium
- Error: returning the API object from an arrow Medium
- Error: incrementing a captured const Easy
- Error: calling the object a factory returned Easy
- Error: calling a closure before its variable is ready Medium
- Error: memoize called without a function Medium
- Error: reading a private variable from outside Easy
- Bug: every menu item opens the last page Easy
- Bug: separate counters share a count Medium
- Bug: the report always says 0 items Hard
- Bug: power(2, 10) returns 8 Medium
- Bug: reset does not reset Easy
Callbacks 30 questions
- What is a callback? Easy
- Is the forEach callback asynchronous? Easy
- setTimeout with 0 ms Easy
- Error-first callbacks Easy
- Callback hell Easy
- Avoiding callback hell Medium
- Inversion of control Hard
- Passing a callback correctly Easy
- Extra arguments to setTimeout Medium
- this inside a callback Medium
- Sometimes sync, sometimes async Hard
- try/catch and async callbacks Hard
- promisify Medium
- Order of parallel callbacks Medium
- Callbacks vs promises Medium
- Error: a missing ) in nested callbacks Easy
- Error: function keyword with => Medium
- Error: a reserved word as a parameter name Medium
- Error: two parameters with the same name Medium
- Error: calling a function without its callback Easy
- Error: passing the result of a call as the callback Easy
- Error: ignoring the error argument Medium
- Error: throwing inside a timer callback Hard
- Error: a string passed to setTimeout Hard
- Error: using a callback's parameter outside it Easy
- Bug: success runs after a failure Medium
- Bug: the result is undefined Easy
- Bug: the welcome message appears twice Medium
- Bug: files are listed in the wrong order Hard
- Bug: the page renders stale content Hard
Promises 30 questions
- The states of a promise Easy
- When does the executor run? Medium
- Calling resolve twice Medium
- What then returns Medium
- Returning a promise from then Medium
- Where should catch go? Easy
- What finally receives Medium
- Promise.all with one failure Medium
- Promise.allSettled Medium
- race vs any Hard
- then vs setTimeout Medium
- Unhandled rejections Hard
- Promise.resolve of a promise Hard
- Thenables Hard
- The explicit-construction anti-pattern Hard
- Error: an unclosed then Easy
- Error: await in a normal function Medium
- Error: a semicolon in the middle of a chain Medium
- Error: async after the arrow parameters Hard
- Error: passing resolve and reject as separate arguments Medium
- Error: new Promise without an executor Medium
- Error: calling then on a function that returns nothing Easy
- Error: a rejection nobody handles Hard
- Error: Promise.all with separate arguments Hard
- Error: Promise.any of an empty list Hard
- Bug: the total is undefined Easy
- Bug: "Order saved" appears before the order is saved Medium
- Bug: "done" is printed before the work Medium
- Bug: shipping an order that failed to load Hard
- Bug: nothing happens for out-of-stock items Hard
Async/Await 30 questions
- What an async function returns Easy
- Where await is allowed Easy
- What await pauses Medium
- Handling a rejected await Easy
- return vs return await inside try Hard
- Running awaits in parallel Medium
- forEach with async callbacks Medium
- Top-level await Medium
- The synchronous part of an async function Medium
- Awaiting a plain value Medium
- An uncaught error in an async function Medium
- async arrow syntax Easy
- await Promise.all with a failure Medium
- Async constructors Hard
- for await…of Hard
- Error: await in a forEach callback Medium
- Error: top-level await in a script Medium
- Error: an async constructor Hard
- Error: an async getter Hard
- Error: await used as a variable name Hard
- Error: an async function whose rejection nobody handles Medium
- Error: using an async result without await Easy
- Error: bad JSON inside an async function Medium
- Error: await Promise.all without error handling Medium
- Error: awaiting a method that does not exist Easy
- Bug: the price prints as a Promise Easy
- Bug: the page loads twice as slowly as needed Medium
- Bug: the order total is 0 Medium
- Bug: the fallback is never used Hard
- Bug: every user is treated as an admin Medium
Event Loop 30 questions
- What the event loop does Easy
- Which callback is a microtask? Easy
- Single-threaded JavaScript Easy
- What setTimeout(fn, 0) means Medium
- How many microtasks run per turn Medium
- Microtask starvation Hard
- A long synchronous loop Medium
- When the Promise executor runs Medium
- process.nextTick vs promises Hard
- Node.js event loop phases Hard
- setImmediate vs setTimeout(0) Hard
- When the browser renders Medium
- try/catch around setTimeout Medium
- Web Workers Medium
- How await resumes Medium
- Error: await inside a setTimeout callback Medium
- Error: an "async" arrow that is not async Hard
- Error: yield inside a timer callback Hard
- Error: the callback is called immediately Easy
- Error: a string passed to setTimeout Medium
- Error: try/catch around setTimeout Medium
- Error: a failure inside queueMicrotask Medium
- Error: using a value set by a timer Easy
- Bug: the progress timer never ticks Medium
- Bug: the result list is empty Easy
- Bug: the spinner appears after the data Medium
- Bug: the Cancel button is ignored Hard
- Bug: the app reports "not ready" Medium
- Bug: the log order changes on the second call Hard
- Bug: await does not wait Medium
DOM Manipulation 30 questions
- What the DOM is Easy
- querySelector with no match Easy
- Showing user input Medium
- Live and static collections Medium
- Event delegation Medium
- Order of event phases Medium
- preventDefault vs stopPropagation Medium
- Reading a data attribute Easy
- Attribute vs property Hard
- Why use a DocumentFragment Medium
- DOMContentLoaded vs load Medium
- The defer attribute Medium
- Removing an event listener Medium
- innerHTML += and listeners Hard
- childNodes vs children Medium
- Error: assigning through optional chaining Medium
- Error: a dashed name on dataset Medium
- Error: an unclosed addEventListener call Easy
- Error: the selector does not match Easy
- Error: a # in getElementById Easy
- Error: forEach on getElementsByClassName Medium
- Error: map on querySelectorAll Medium
- Error: appendChild with an HTML string Medium
- Error: a number method on a data attribute Medium
- Bug: a comment injects an image with a script Medium
- Bug: the Like button stops working Medium
- Bug: delete removes "undefined" Hard
- Bug: only some finished tasks are cleared Hard
- Bug: the active tab is not detected Easy
- Bug: the progress bar does not grow Medium
Error Handling 30 questions
- When finally runs Easy
- Reading a property of null Easy
- Using an undeclared variable Easy
- Catching a SyntaxError Medium
- Why throw Error objects Medium
- Writing a custom error Medium
- return inside finally Hard
- error.cause Medium
- AggregateError Medium
- catch without a parameter Easy
- Ordering instanceof checks Medium
- try/catch and promises Medium
- Converting an error to a string Easy
- Empty catch blocks Easy
- Global error handlers Hard
- Error: try on its own Easy
- Error: two parameters in catch Medium
- Error: a line break after throw Hard
- Error: a custom error without super() Medium
- Error: a custom error class called without new Medium
- Error: a variable from try used in catch Medium
- Error: a broken cleanup in finally Hard
- Error: a bug inside the catch block Easy
- Error: re-throwing the wrong name Medium
- Bug: the port is silently undefined Easy
- Bug: the custom error prints as "Error" Medium
- Bug: validation errors get the generic message Medium
- Bug: the error is printed as a result Medium
- Bug: the logs never show why loading failed Medium
- Bug: the spinner never disappears after an error Medium
JavaScript Output Questions 15 questions
- typeof typeof Easy
- Which comparison is true? Easy
- The type of NaN Easy
- 0.1 * 3 Medium
- "10" + 1 - 1 Medium
- [] == false Medium
- Which value is truthy? Easy
- Math.max with an array Medium
- The length of an emoji Hard
- new Array(3) as a string Medium
- Unary plus on an object Medium
- Comparing numeric strings Medium
- delete on an array element Medium
- let a = b = 5 Hard
- Default sort on numbers Easy
Ready to test your Programming?
Timed online tests with instant scores and explanations.