When a const variable is declared in a block scope, what is the scope of this variable?

  • Local to the block
  • Global
  • Function-level
  • Lexical scope
In JavaScript, when you declare a constant variable (const) inside a block (like an if statement or a loop), the scope of that variable is limited to the block. This means it cannot be accessed outside of that block.

ES6 enables deeper recursion without a stack overflow by using _________ tail calls.

  • Deferred
  • Optimized
  • Asynchronous
  • Tail
In-depth content in the explanation. ES6 introduces the concept of tail call optimization, allowing for deeper recursion without causing a stack overflow. Tail calls occur when a function's last action is a recursive call, and ES6 optimizes these tail calls to prevent excessive stack usage.

A Map in JavaScript can have keys of any type, unlike an object which has keys of type _________.

  • any
  • varied
  • string
  • object
Unlike objects, where keys are converted to strings, a Map in JavaScript can have keys of any data type. So, the correct answer is string.

A variable declared with let can be redeclared in a different __________ but not in the same scope.

  • block
  • function
  • module
  • statement
The correct option is 'block'. In JavaScript, a variable declared with 'let' has block-level scope. This means it can be redeclared within a different block, such as within a different if statement or loop. However, attempting to redeclare it in the same block or scope will result in an error.

A for...of loop is best suited for iterating over ________ data structures, like arrays and strings.

  • asynchronous
  • asymmetric
  • iterable
  • immutable
The for...of loop is designed for iterating over iterable data structures, such as arrays and strings. It simplifies the process of iterating over the values without the need for index management.

Consider a scenario where you have an array of numbers, and you need to create a new array with only the numbers greater than 10. Which method would you use?

  • filter
  • map
  • reduce
  • forEach
In this scenario, the most suitable array method is filter. The filter method is designed for creating a new array containing elements that pass a certain condition. It allows you to filter out numbers greater than 10 effectively.

If you have a Symbol mySymbol, you can access its description using mySymbol.__________.

  • name
  • description
  • valueOf
  • toString
The correct property to access the description of a Symbol is description. The description property is used to get or set the description of a Symbol, providing additional information about the Symbol.

When a generator function is initially called, it returns a(n) __________ object.

  • Generator
  • Promise
  • Iterator
  • Iterable
When a generator function is called, it returns an iterator object. This object can be used to iterate through the values generated by the generator using the next() method. The other options do not represent the initial return type of a generator function.

How does ES6 support dynamic property names in object literals?

  • Computed Property Names
  • Object Linking
  • Dynamic Key Binding
  • Property Aliasing
ES6 supports dynamic property names through computed property names. By using square brackets around an expression within an object literal, you can create properties with names determined at runtime. This enhances the flexibility and expressiveness of object literals.

Tree shaking is most effective when modules use _______ exports rather than wildcard exports.

  • Named
  • Default
  • All
  • Individual
Tree shaking is a technique in JavaScript used to eliminate unused code during the build process. When modules use named exports, it allows the bundler to selectively include only the functions or variables that are actually used, making tree shaking more effective. Default exports and wildcard exports can complicate this process, leading to less efficient tree shaking.