Arrow functions are not suitable for defining _________ functions.

  • async
  • generator
  • anonymous
  • recursive
Arrow functions do not work well for defining generator functions. Generator functions use the function* syntax and rely on the yield keyword, which doesn't behave as expected in arrow functions. Therefore, the correct option is generator.

The mechanism of closing over variables is a core concept in ________ programming in JavaScript.

  • Functional
  • Object-Oriented
  • Asynchronous
  • Procedural
The mechanism of closing over variables is a core concept in "Functional" programming in JavaScript. Functional programming promotes the use of pure functions and emphasizes the importance of avoiding mutable state. Closures play a vital role in functional programming by allowing functions to capture and remember the surrounding state.

How can you select an element within a specific parent element using JavaScript?

  • querySelector()
  • getElementById()
  • selectElementInParent()
  • getElementsByParent()
In JavaScript, you can use the querySelector() method to select an element within a specific parent element. This method allows you to specify a CSS selector that matches the desired element. For example, parentElement.querySelector('.child') will select the first child element with the class 'child' within parentElement.

In what scenario might you prefer to use a function expression over an arrow function?

  • When needing a concise syntax.
  • When you want to bind this explicitly.
  • When working with callbacks in event handling.
  • When using async/await for asynchronous code.
You might prefer to use a function expression (a regular function) over an arrow function when you need to explicitly bind the this context, especially in cases where you want to define methods inside objects or use constructors. Function expressions allow you to use the this keyword as expected, while arrow functions inherit this from their lexical enclosing context.

You are debugging a piece of code and encounter a variable declaration let [a, b, ...rest] = [10, 20, 30, 40, 50];. What will be the value of rest?

  • [30, 40, 50]
  • [10, 20]
  • [20, 30, 40, 50]
  • [undefined, undefined]
The value of rest will be [30, 40, 50]. This code uses destructuring assignment to assign the first two elements to a and b, and the rest of the elements to rest using the rest parameter (...). So, a will be 10, b will be 20, and rest will contain [30, 40, 50].

When you want to store multiple values in a single variable, you should use a(n) _________.

  • "array"
  • "object"
  • "string"
  • "function"
To store multiple values in a single variable in JavaScript, you should use an array. An array is a data structure that can hold multiple values of different data types. It is created using square brackets, like this: var myArray = [value1, value2, value3];. Arrays are versatile and commonly used for tasks like storing lists of items or organizing data.

Which property allows you to change the HTML content of an element?

  • textContent
  • innerText
  • innerHTML
  • innerTextContent
The innerHTML property allows you to change the HTML content of an element in JavaScript. It is often used to set or modify the content of an element and can include HTML tags. However, be cautious when using innerHTML to avoid potential security issues, such as cross-site scripting (XSS).

If you want to convert a JavaScript object to a string in the Fetch API, you should use the _________ method.

  • parse()
  • serialize()
  • stringify()
  • convert()
In the Fetch API, you should use the JSON.stringify() method to convert a JavaScript object to a string. This method serializes the object into a JSON string, which is a common way to send structured data in HTTP requests and responses. parse() is used for JSON parsing.

The ________ interface provides methods to deal with HTTP responses represented in binary format.

  • a) TextDecoder Interface
  • b) FormData Interface
  • c) Blob Interface
  • d) ArrayBuffer Interface
The Blob interface provides methods to deal with HTTP responses represented in binary format. It allows you to work with binary data such as images, audio, or other binary content in a more efficient way. This is essential when handling binary data in web applications.

You're debugging a piece of code and find an unexpected type coercion in a comparison. Which operator is most likely being used that could cause this issue?

  • == (Equality)
  • === (Strict Equality)
  • > (Greater Than)
  • != (Inequality)
The double equal operator (==) performs type coercion during comparison, which means it converts the operands to the same type before comparing. This can lead to unexpected results when comparing values of different types, potentially causing type coercion issues in your code. You should generally prefer strict equality (===) to avoid type coercion.