Modern JavaScript (ES6+)

Last Updated :
Discuss
Comments

Question 1

Which keyword is used to export a function from a module in ES6?

  • A

    module.exports

  • B

    export

  • C

    exports

  • D

    define

Question 2

What does the Promise.allSettled() method return?

  • A

    Resolves if all promises are fulfilled

  • B

    Rejects if any promise is rejected

  • C

    Returns an array with the results of all promises, regardless of their status

  • D

    Cancels unresolved promises

Question 3

What is the result of the following code?

JavaScript
const obj = { a: 1, b: 2 };
const { a, b } = obj;
console.log(a, b);


  • A

    { a: 1, b: 2 }

  • B

    1 2

  • C

    undefined undefined

  • D

    Error

Question 4

What does the Symbol type represent in JavaScript?

  • A

    A unique, immutable primitive value

  • B

    A reference to an object

  • C

    A deprecated data type

  • D

    A special property of arrays

Question 5

Which syntax allows combining multiple arrays into one?

  • A

    Array.prototype.concat()

  • B

    Spread operator (...)

  • C

    Both a and b

  • D

    Rest operator (...)

Question 6

What is the purpose of optional chaining (?.)?

  • A

    Prevents accessing properties on null or undefined objects

  • B

    Accesses private properties

  • C

    Automatically assigns default values

  • D

    Handles circular references

Question 7

Which feature allows embedding variables inside strings?

  • A

    String interpolation (#)

  • B

    Template literals (````)

  • C

    Spread operator (...)

  • D

    String concatenation

Question 8

What does the rest operator (...) do?

  • A

    Combines multiple arrays into one

  • B

    Collects remaining elements into an array or object

  • C

    Spreads an array into individual elements

  • D

    Executes asynchronous code

Question 9

What is the output of the following code?

JavaScript
const arr = [1, 2, 3];
const result = [...arr, 4, 5];
console.log(result);


  • A

    [1, 2, 3, 4, 5]

  • B

    [[1, 2, 3], 4, 5]

  • C

    [4, 5, 1, 2, 3]

  • D

    Error

Question 10

What is the purpose of Promise.any()?

  • A

    Resolves when all promises are fulfilled

  • B

    Resolves when the first promise is fulfilled

  • C

    Resolves or rejects based on the fastest promise

  • D

    Resolves when the first promise is fulfilled or rejects when all promises fail

There are 10 questions to complete.

Take a part in the ongoing discussion