The _______ operator can be used to unpack the values from an iterable into individual elements.

  • spread
  • merge
  • combine
  • join
The spread operator (...) in JavaScript is used to unpack elements from an iterable, such as an array, and spread them into individual elements or combine them with other elements.

What happens when you try to create a new Symbol using the new keyword?

  • Error is thrown
  • A new Symbol is created
  • It returns an existing Symbol
  • Symbols cannot be created using new
When attempting to create a Symbol using the new keyword, it results in an error. Symbols are primitive values, and using the new keyword with them is not allowed. Symbols are typically created without the new keyword.

In a project using ES6 modules, if you need to dynamically load a module based on a user's action, which import method would you use?

  • import()
  • require()
  • import dynamic
  • import lazy
In ES6, the import() function allows dynamic loading of modules. It returns a promise that resolves to the module namespace object, allowing you to load modules conditionally or based on user actions.

If you are implementing a function that will be used as a callback, which might benefit from lexical scoping of this, what type of function would you choose?

  • Arrow function
  • Regular function
  • Class method
  • Anonymous function
Arrow functions are suitable for callbacks, as they capture the "this" value from their enclosing scope, providing a clean and concise way to maintain lexical scoping.

When destructuring an array, the syntax _________ is used to skip over elements.

  • ...
  • ++
  • //
  • --
Destructuring an array in ES6 allows for skipping elements using the spread/rest syntax .... This is particularly useful when certain elements are not needed in the assignment.

A class in ES6 is a special type of function, and it can be declared using the ________ keyword.

  • function
  • class
  • object
  • define
In ES6, the class keyword is used to declare a class. Unlike functions, classes support class-based inheritance, providing a cleaner syntax for object-oriented programming in JavaScript.

Which tool is essential for enabling tree shaking in a modern JavaScript project?

  • Webpack
  • Babel
  • ESLint
  • npm
Tree shaking is a process in Webpack that eliminates unused code, reducing the bundle size. By configuring Webpack properly, you can enable tree shaking and optimize your project for better performance.

A const declaration ensures that the variable's __________ cannot be reassigned.

  • type
  • value
  • identity
  • scope
The correct option is 'value'. When a variable is declared with 'const' in JavaScript, its value cannot be reassigned. However, it's important to note that the const declaration does not make the variable itself immutable; it only ensures that the binding of the variable to a value remains constant.

Iterators enable lazy evaluation, allowing elements to be processed one at a time, as opposed to ________ evaluation.

  • synchronous
  • asynchronous
  • parallel
  • concurrent
Iterators in JavaScript enable lazy evaluation, meaning elements are processed one at a time on demand, in contrast to synchronous evaluation, where all elements are processed at once. This supports more efficient resource utilization.

Can a Symbol be automatically converted to a string when concatenated with a string?

  • Yes, Symbols are automatically converted to strings
  • No, attempting to concatenate a Symbol with a string will result in an error
  • Only if the Symbol has an associated description
  • Symbols cannot be concatenated with strings
No, a Symbol cannot be automatically converted to a string when concatenated with a string. Attempting to do so will not result in an error but will create a new string that includes the Symbol's description, if available, or the string representation of the Symbol.