HomeCode HereModern JavaScript quiz Modern JavaScript quiz Admin 1 min read Updated November 16, 2026 Nine questions on destructuring, spread, array methods, modules and classes. JavaScript Modern JavaScript quiz 9 questions, instant feedback Question 1 of 9 Which line extracts name from an object? A const { name } = user B const [ name ] = user C const name = user->name D const name = user::name Object destructuring uses braces and matches property names. Square brackets destructure arrays by position. Question 2 of 9 What does [...items] create? A A reference to items B A shallow copy of items C A string D A deep copy Spread copies the top level. Nested objects are still shared, which is why deep updates need care. Question 3 of 9 Which method returns a new array of transformed items? A forEach B map C filter D find map returns one new value per item. forEach returns undefined and is for side effects. Question 4 of 9 Which method keeps only items that pass a test? A map B reduce C filter D some filter returns a new array containing the items for which the callback returned true. Question 5 of 9 What does reduce need besides a callback? A A starting value B A second array C A boolean D A DOM element The accumulator starts from the initial value you pass. Without one, the first item becomes the initial accumulator and empty arrays throw. Question 6 of 9 Which syntax imports a named export? A import { load } from './data.js' B import load from './data.js' C require('./data.js').load D include './data.js' Named exports are imported with braces. A default export uses the form without braces. Question 7 of 9 What is a class constructor for? A Creating a new file B Initialising an object's state when it is created C Importing modules D Handling errors The constructor runs on new and sets up the instance. Methods live on the prototype and are shared. Question 8 of 9 What does user?.name do when user is null? A Throws an error B Returns undefined C Returns an empty string D Creates the object Optional chaining short-circuits and returns undefined instead of throwing on null or undefined. Question 9 of 9 Which operator falls back only for null or undefined? A || B ?? C && D ?. ?? uses the right side only for null or undefined. || also falls back for 0, empty string and false. Check my answers Try again Your answers stay in this browser. Nothing is sent to a server. More quizzes JavaScript async and data quiz 9 questions JavaScript final quiz 10 questions JavaScript basics quiz Coming soon All quizzes