What is the primary difference between for...in and for...of loops?

  • The order of iteration and syntax
  • The type of objects they iterate over
  • They are interchangeable
  • The number of iterations they perform
The primary difference between for...in and for...of loops is in their order of iteration and syntax. For...in is used for iterating over object properties, while for...of is used for iterating over the values of iterable objects, like arrays and strings, and maintains the order.

Which of the following is a way to create a singleton object in JavaScript?

  • Using the Factory Pattern
  • Using the Prototype Pattern
  • Using the Singleton Pattern
  • Using the Module Pattern
A singleton object in JavaScript is typically created using the Module Pattern. The Module Pattern allows you to encapsulate code and create a single instance of an object, ensuring that only one instance of the object exists throughout your application. The other options (Factory, Prototype, and Singleton patterns) serve different purposes.

What was the main reason for JavaScript's creation at Netscape?

  • To compete with Microsoft's JScript
  • To create a replacement for HTML
  • To enhance interactivity in web browsers
  • To provide a server-side scripting language
JavaScript was primarily created to enhance interactivity in web browsers. It allowed developers to manipulate web page elements and respond to user actions, making websites more dynamic. While JavaScript later found uses on the server-side as well, its initial purpose was to enhance the client-side user experience.

The for...in loop will also iterate over the _______ properties of an object.

  • Enumerable
  • Non-enumerable
  • Private
  • Prototype
The for...in loop will also iterate over the enumerable properties of an object. Enumerable properties are those that can be iterated over using for...in, typically the object's own properties. Non-enumerable properties, private properties, and prototype properties are not included in this iteration.

If no case matches in a switch statement and there is no default case, the control is passed to the _________.

  • Next statement
  • Previous case
  • Last case
  • Next iteration
If no case matches in a switch statement and there is no default case, the control is passed to the next statement after the switch. This behavior is important to understand because it determines what happens when none of the cases match the expression value.

What does the "this" keyword refer to in JavaScript?

  • The current function
  • The parent object
  • The global object
  • The previous function call
In JavaScript, the "this" keyword typically refers to the parent object, which is the object that calls the function. It allows you to access and manipulate the properties and methods of that object within the function. This behavior is crucial for object-oriented programming in JavaScript.

In JavaScript, the Symbol data type can be used to create _________.

  • Objects
  • Functions
  • Unique identifiers
  • Private variables
In JavaScript, the Symbol data type can be used to create unique identifiers. Symbols are often used as object property keys when you need to ensure that the key is unique and not accidentally overwritten. They are not used to create objects, functions, or private variables.

A _______ function is a function that accepts up to three arguments: the value of the element, the index of the element, and the array object being traversed.

  • callback
  • handler
  • middleware
  • delegate
In JavaScript, a callback function is a function that can be passed as an argument to another function. Callback functions can accept up to three arguments: the value of the element, the index of the element, and the array object being traversed. They are commonly used in asynchronous programming and array methods.

Considering browser compatibility, which array method would you avoid in Internet Explorer 8?

  • forEach()
  • map()
  • filter()
  • indexOf()
In terms of browser compatibility, the forEach() method should be avoided in Internet Explorer 8. This method was introduced in ECMAScript 5, and Internet Explorer 8 only supports ECMAScript 3. Other methods like map(), filter(), and indexOf() have more widespread support in older browsers.

The HTTP status code ________ indicates that the request has succeeded.

  • 200 OK
  • 204 No Content
  • 404 Not Found
  • 500 Internal Server Error
The HTTP status code 200 OK indicates that the request has succeeded. It is the standard response for successful HTTP requests. The other options represent different HTTP status codes with different meanings, such as 'No Content,' 'Not Found,' and 'Internal Server Error.'