The "super" keyword in JavaScript is used to call methods on a parent class, and it should be called within the constructor method of the child class, before using the "this" keyword, otherwise it will result in a reference error, stating that "this is not _________.

  • Defined
  • Valid
  • a Function
  • Accessible
The "super" keyword in JavaScript is used to call methods on a parent class within the constructor method of the child class. If it is not called before using the "this" keyword, it will result in a reference error, stating that "this is not a function." This highlights the importance of calling "super" before accessing the properties and methods of the parent class.

You are debugging a web page and find that an element isn't being selected as expected with document.querySelector('.example'). What could be a possible reason if the class name is correct?

  • Element not present in the DOM
  • Element is inside an iframe
  • JavaScript not loaded before the query
  • Class name contains special characters or spaces
If an element with the correct class name isn't being selected with document.querySelector('.example'), a possible reason could be that the element is not present in the DOM at the time of the query. Ensure that the element you are trying to select exists and is rendered when your JavaScript runs. The other options are less likely causes.

In JavaScript, the _______ method is used to create a new object using an existing object as the prototype of the newly created object.

  • Object.create()
  • Object.assign()
  • Object.extend()
  • Object.instantiate()
In JavaScript, the Object.create() method is used to create a new object with the specified prototype object. It allows you to create objects that inherit properties and methods from an existing object, making it a powerful tool for prototypal inheritance.

The switch statement evaluates expressions based on their _________.

  • Values
  • Cases
  • Conditions
  • Labels
The switch statement in JavaScript evaluates expressions based on their cases. Each case represents a possible value that the expression can take, and the code block associated with the matching case is executed. This allows for multiple execution paths based on different values of the expression.

When using a for...of loop with strings, each iteration will provide a single _______.

  • Character
  • Word
  • Line
  • Number
When using a for...of loop with strings, each iteration will provide a single character. This loop is useful for breaking down strings into individual characters for various processing tasks, such as counting characters or manipulating them individually.

Imagine you are implementing a feature to upload a file to the server. Which HTTP method would be most appropriate to use with the Fetch API for this purpose?

  • GET
  • POST
  • PUT
  • DELETE
To upload a file to the server, you would use the POST HTTP method with the Fetch API. The POST method is used for submitting data to be processed to a specified resource, which is suitable for file uploads. GET, PUT, and DELETE have different purposes.

How to declare a constant array in JavaScript?

  • const arr = [];
  • const arr = new Array();
  • const arr = {}
  • const arr = [1, 2, 3];
To declare a constant array in JavaScript, you can use the const keyword followed by square brackets, like const arr = [];. The const keyword ensures that the variable arr cannot be reassigned, making it a constant array.

You're developing a Node.js application and notice that the "this" keyword inside a regular function, defined in the global scope, refers to something different than you're used to in client-side JavaScript. What does "this" refer to in this context?

  • It refers to the Node.js global object (e.g., "global" or "window")
  • It refers to the "exports" object
  • It refers to the "module.exports" object
  • It refers to the function itself
In Node.js, when you define a regular function in the global scope (outside any function or module), "this" inside that function refers to the Node.js global object (e.g., "global" in Node.js or "window" in the browser). This behavior is different from client-side JavaScript, where "this" in the global scope refers to the global window object.

What is a closure in JavaScript?

  • A secure way to store passwords
  • A private function
  • A way to handle exceptions
  • A function that remembers its lexical scope
A closure in JavaScript is a function that "remembers" its lexical scope, even when it's executed outside that scope. This allows the function to maintain access to variables from its parent scope, creating a powerful mechanism for encapsulation and data privacy.

Can a function expression be used before it is defined in the code?

  • No, function expressions can only be used after their definition.
  • Yes, function expressions are hoisted and can be used before they are defined.
  • It depends on whether the function expression is named or anonymous.
  • No, function expressions are not valid in JavaScript.
Function expressions are not hoisted in JavaScript, which means they can only be used after they are defined in the code. Attempting to use a function expression before its declaration will result in an error. This is different from function declarations, which are hoisted and can be used before their declaration. It's essential to understand this behavior to avoid bugs and unexpected behavior in your JavaScript programs.