ECMAScript (ES7 + ES8 + ES9 + ES10) New Features Quiz

Assess your level of knowledge of the new features that have been incorporated into the ECMAScript language in versions 7, 8, 9, and 10.

Question 1/15

What is the ** operator introduced in ES7 used for?

Question 2/15

Which of the following is a new data type introduced in ES7?

Question 3/15

What new feature was introduced in ES9 that provides a more convenient way to convert arrays and objects to maps?

Question 4/15

Which of the following is a new feature introduced in ES9 that improves support for parallelism in JavaScript?

Question 5/15

Which of the following is a new method introduced in ES7 for arrays?

Question 6/15

What new feature was introduced in ES10?

Question 7/15

What new feature was introduced in ES9 that provides a more concise way to pad strings with whitespace?

Question 8/15

Which of the following is a new feature introduced in ES8 that allows for more concise function syntax?

Question 9/15

What new feature was introduced in ES8 that allows for more flexible object property definitions?

Question 10/15

Which of the following is a new feature introduced in ES8, ES9, and ES10?

Question 11/15

What new feature was introduced in ES8?

Question 12/15

Which of the following is a new feature introduced in ES10 that provides a more convenient way to merge arrays?

Question 13/15

What new feature was introduced in ES10 that allows for the chaining of optional properties and methods?

Question 14/15

Which of the following is a new feature introduced in ES9?

Question 15/15

Which of the following is a new feature introduced in ES9 that improves support for Unicode?
You did not answer any questions correctly.

Your Answers

Question 1/15

What is the ** operator introduced in ES7 used for?

The ** operator is the exponentiation operator introduced in ES7. It raises the left operand to the power of the right operand.

Exponentiation is a mathematical operation that involves raising a base number to a power. In other words, it is a shorthand way of writing repeated multiplication of a number by itself. The base number is multiplied by itself as many times as indicated by the exponent or power. For example, 2 raised to the power of 3 (written as 2^3) means multiplying 2 by itself 3 times (2 * 2 * 2), resulting in 8.

// using the ** operator
let x = 2;
let y = 3;
let result = x ** y; // result = 8 (2 raised to the power of 3)

// using the Math.pow() method
let a = 4;
let b = 2;
let output = Math.pow(a, b); // output = 16 (4 raised to the power of 2)

Question 2/15

Which of the following is a new data type introduced in ES7?

ES7 introduced the BigInt data type, which allows you to represent integers larger than 2^53 - 1

Question 3/15

What new feature was introduced in ES9 that provides a more convenient way to convert arrays and objects to maps?

ES9 introduced the Object.fromEntries() method, which provides a more convenient way to convert arrays and objects to maps by taking an array of key-value pairs and returning a new map object.

Question 4/15

Which of the following is a new feature introduced in ES9 that improves support for parallelism in JavaScript?

ES9 introduced the SharedArrayBuffer object, which provides a low-level mechanism for sharing data between JavaScript threads and improving support for parallelism.

Question 5/15

Which of the following is a new method introduced in ES7 for arrays?

ES7 introduced the includes() method for arrays, which returns true if an element is found in the array, and false otherwise. This is similar to the indexOf() method, but is more concise and easier to read.

Question 6/15

What new feature was introduced in ES10?

ES10 introduced nullish coalescing, which is a new way of handling nullish values in JavaScript using the ?? operator.

const x = null;
const y = x ?? 'default value';
console.log(y); // output: "default value"

Question 7/15

What new feature was introduced in ES9 that provides a more concise way to pad strings with whitespace?

ES9 introduced the String.prototype.padStart() and String.prototype.padEnd() methods, which provide a more concise way to pad strings with whitespace by specifying the desired length and the character to use for padding.

Question 8/15

Which of the following is a new feature introduced in ES8 that allows for more concise function syntax?

ES8 introduced the arrow function syntax, which allows for more concise function syntax by removing the need for the function keyword and using a shorter syntax for one-line functions.

Question 9/15

What new feature was introduced in ES8 that allows for more flexible object property definitions?

ES8 introduced object property descriptors, which allow for more flexible object property definitions by specifying configurable, enumerable, and writable attributes for each property. This feature also provides a way to define getter and setter functions for computed properties.

// define an object
const person = {
  name: 'John',
  age: 30
};

// define a property descriptor for the "name" property
const nameDescriptor = Object.getOwnPropertyDescriptor(person, 'name');
console.log(nameDescriptor);

// modify the "age" property to be read-only
Object.defineProperty(person, 'age', { writable: false });
person.age = 35; // throws a TypeError

console.log(person.age); // output: 30

In this example, we define an object called person with two properties: name and age. We then use the Object.getOwnPropertyDescriptor() method to retrieve the property descriptor for the name property. The resulting descriptor object contains information about the name property, including whether it is writable, enumerable, and configurable.

Next, we use the Object.defineProperty() method to modify the age property to be read-only. This is done by passing an options object with writable: false as the third argument to the method. This means that any attempt to modify the age property using the assignment operator (=) will result in a TypeError being thrown.

Finally, we attempt to assign a new value to the age property and log its value to the console. Since the age property is read-only, the assignment throws a TypeError. The value of the age property remains unchanged at 30.

Question 10/15

Which of the following is a new feature introduced in ES8, ES9, and ES10?

The flat() method for arrays was introduced in ES8, and its variations, flatMap() and flatten(), were introduced in ES9 and ES10, respectively. This method allows you to flatten a nested array by concatenating all subarrays into a single array.

Question 11/15

What new feature was introduced in ES8?

ES8 introduced async/await, which is a new way of writing asynchronous code in JavaScript that makes use of promises and the async and await keywords.

Question 12/15

Which of the following is a new feature introduced in ES10 that provides a more convenient way to merge arrays?

ES10 introduced the flat() method for arrays, which provides a more convenient way to merge arrays by concatenating subarrays into a single array. The flat() method also supports an optional depth parameter that specifies how many levels of nested arrays to flatten.

Question 13/15

What new feature was introduced in ES10 that allows for the chaining of optional properties and methods?

ES10 introduced optional chaining, which allows for the chaining of optional properties and methods without throwing a TypeError if a property or method is undefined or null.

const person = {
  name: 'John',
  age: 30,
  address: {
    city: 'New York',
    zip: 12345
  }
};

// accessing a property with optional chaining
const cityName = person.address?.city;
console.log(cityName); // output: "New York"

// accessing a non-existent property with optional chaining
const stateName = person.address?.state;
console.log(stateName); // output: undefined

In this example, we define an object called person that has three properties: name, age, and address. The address property is itself an object with two properties: city and zip.

We then use the optional chaining operator ?. to access the city property of the address object. Since the address property exists on the person object, the expression person.address?.city evaluates to 'New York'. The resulting value is then assigned to the cityName variable, which is logged to the console.

In the second part of the example, we attempt to access the non-existent state property of the address object using optional chaining. Since the state property does not exist, the expression person.address?.state evaluates to undefined. The resulting value is then assigned to the stateName variable, which is also logged to the console.

Question 14/15

Which of the following is a new feature introduced in ES9?

ES9 introduced asynchronous iteration, which is a new way of iterating over asynchronous data sources using the for await...of loop.

// asynchronous iterable
const iterable = {
  async *[Symbol.asyncIterator]() {
    yield Promise.resolve(1);
    yield Promise.resolve(2);
    yield Promise.resolve(3);
  }
};

// asynchronous loop
async function asyncLoop() {
  for await (let value of iterable) {
    console.log(value);
  }
}

// call the asynchronous loop function
asyncLoop();

In this example, we define an asynchronous iterable object with a Symbol.asyncIterator method that returns an async generator function. The generator function yields three promises that resolve to values of 1, 2, and 3.

We then define an asynchronous loop function called asyncLoop that uses the for await...of loop to iterate through the asynchronous iterable object. Each value yielded by the iterable is assigned to the value variable, and this value is logged to the console using console.log(value).

Finally, we call the asyncLoop function to execute the asynchronous loop and print the values 1, 2, and 3 to the console.

Question 15/15

Which of the following is a new feature introduced in ES9 that improves support for Unicode?

ES9 introduced the String.prototype.trimStart() and String.prototype.trimEnd() methods, which allow you to remove whitespace characters from the beginning and end of a string, respectively. These methods support Unicode characters, making them more robust than the existing String.prototype.trim() method.

Take Another Quiz

Advanced CSS Quiz

Advanced CSS Quiz designed to test your knowledge of advanced CSS concepts, including layout, positioning, blending, and responsive design. Start quiz

Agile Methodologies Quiz

Test your understanding of Agile methodologies, including Scrum, Kanban, and Lean. Understand how to use Agile principles to enhance the efficiency and productivity of your software development projects. Start quiz

Basic HTML & CSS Quiz

From basic tags and selectors to layout and positioning, this quiz covers essential topics that every beginner frontend web developer should know. Start quiz

Basic JavaScript Quiz

Test your understanding of the fundamental concepts and syntax of JavaScript, including variables, data types, conditionals, loops, and functions. Start quiz

CSS Box Model Quiz

Identify the correct box model properties for various layout scenarios and determine how changes to these properties affect the appearance of an element. Start quiz

CSS Flexbox Quiz

Test your knowledge of the CSS Flexbox layout module with multiple choice questions and their explanations. Start quiz