Any2Quiz
Quizzes / Computer Science / Languages / JavaScript

ES6+ Quiz - Languages JavaScript

Free practice quiz: ES6+ (Languages JavaScript). 56 multiple-choice questions with answers and explanations. Play online, no sign-up needed.

This Languages JavaScript practice quiz has 56 multiple-choice questions on ES6+, and 56 of them come with an explanation. Try the 5 sample questions below (tap an option to check yourself), then play the full quiz online. No sign-up needed.

Start quiz: 56 questions, free

Sample questions

  1. Which of the following correctly declares a constant variable in JavaScript ES6?

    Show answer

    Answer: C. const PI = 3.14;

    In ES6, the `const` keyword is used to declare variables whose values cannot be reassigned. `var` and `let` declare variables that can be reassigned, and `constant` is not a valid JavaScript keyword for variable declaration.

  2. What does the `async` keyword in ES6 signify?

    Show answer

    Answer: C. It declares a function that implicitly returns a Promise

    An `async` function always returns a Promise. If the function returns a non-Promise value, it's wrapped in a resolved Promise. If it throws an error, it returns a rejected Promise.

  3. Consider the code: `let x = 10; function outer() { let x = 20; function inner() { console.log(x); } inner(); } outer();`. What is logged?

    Show answer

    Answer: B. 20

    JavaScript uses lexical scoping. The `inner` function is within the scope of `outer`, which has its own `x` variable with the value `20`. Therefore, `inner` accesses `x` from `outer`'s scope, not the global scope.

  4. What is the purpose of the `Symbol.iterator` method in ES6?

    Show answer

    Answer: A. To define how an object can be iterated over

    The `Symbol.iterator` is a method that is called when a `for...of` loop or other iterable consumption methods are used on an object. It returns an iterator object, which implements the iterator protocol.

  5. What is a WeakMap in ES6?

    Show answer

    Answer: B. A Map where keys are weakly held, allowing garbage collection if the key is no longer referenced elsewhere

    Unlike a `Map`, keys in a `WeakMap` must be objects and are held weakly. If an object used as a key is garbage collected, the entry in the `WeakMap` is automatically removed.

Take the full quiz

More questions in this quiz

Answers and explanations are in the full quiz.

  1. What is the output of `console.log([...[1, 2], ...[3, 4]]);` in ES6?
  2. What does the arrow function `((a, b) => a + b)(5, 3)` return?
  3. Which statement correctly uses template literals in ES6?
  4. What is the purpose of the `let` keyword in ES6?
  5. Consider the following code: `const arr = [1, 2, 3]; const [a, b] = arr; console.log(a);`. What will be logged?
  6. What is a default parameter in JavaScript ES6?
  7. What does `const { name, age } = { name: 'Alice', age: 30 };` do?
  8. Which of the following is a valid ES6 class declaration?
  9. What is the output of `console.log(Promise.resolve(5))`?
  10. What is a generator function in ES6?
  11. What does the `await` keyword in ES6 do?
  12. What is a Symbol in ES6?
  13. What does the `Map` object in ES6 represent?
  14. What is the purpose of the `Set` object in ES6?
  15. What is the output of `console.log(String.fromCharCode(65))`?
  16. Which ES6 feature allows you to define a function that takes a variable number of arguments as an array?
  17. What is `Object.assign()` used for in ES6?
  18. What is the output of `console.log(Math.max(...[1, 5, 2]))`?
  19. Which of the following is NOT a new primitive type introduced in ES6?
  20. What is the difference between `Array.prototype.map()` and `Array.prototype.forEach()` in ES6?
  21. What does the `finally` block in a `try...catch...finally` statement do?
  22. What is the output of `console.log(typeof null)`?
  23. What is the primary benefit of using `const` over `let`?
  24. Which of these is NOT a valid way to create an object in JavaScript?
  25. What is the result of `console.log(2 + '3' * 2)`?
  26. Which ES6 feature is used to create promises that can be chained together?
  27. What is the primary difference between `let` and `var` regarding scope in ES6?
  28. What will `console.log('hello'.repeat(3))` output?
  29. Which ES6 method can be used to check if an array includes a certain element?
  30. What is the output of `console.log(0.1 + 0.2 === 0.3)`?
  31. What is the output of `const x = 10; if (true) { let x = 20; } console.log(x);`?
  32. Which of the following is an example of a default parameter in an ES6 arrow function?
  33. What is the difference between `Object.keys()` and `Object.values()` in ES6?
  34. What does the `entries()` method of a Map return in ES6?
  35. What is the result of `console.log('abc'.padStart(5, 'x'))`?
  36. Which ES6 feature is used to create a shallow copy of an array?
  37. What does the `for...of` loop iterate over in ES6?
  38. What is the purpose of `Object.entries()` in ES6?
  39. What is the output of `console.log(String.prototype.includes.call('JavaScript', 'Script'))`?
  40. What is a Proxy in ES6?
  41. What does the `Array.from()` method do in ES6?
  42. What is the primary purpose of the `Reflect` object in ES6?
  43. What does `const myString = 'Hello'; console.log(myString[0]);` output?
  44. Which ES6 feature provides a more direct way to handle promises than traditional callback chaining?
  45. What is the output of `console.log(typeof typeof 1);`?
  46. What does the `Object.getOwnPropertyDescriptor()` method return for a given property of an object?
  47. What is the result of `let a = [1, 2]; let b = a; b.push(3); console.log(a);`?
  48. Which ES6 feature allows for cleaner syntax for creating functions that return values when immediately invoked?
  49. What is the output of `console.log(typeof NaN)`?
  50. What does the `Array.prototype.fill()` method do in ES6?
  51. Which ES6 feature allows you to define a function that returns a Promise and can pause its execution until another Promise resolves?

More quizzes

Browse all JavaScript quizzes

More to play

Daily ChallengeA new quiz every day. Keep your streak.HangmanGuess the word, letter by letter.Story QuestLearn through short interactive stories.All quizzesCBSE, ICSE, competitive exams and more.