The querySelector method uses _______ selectors to select elements.

  • CSS
  • XPath
  • JSON
  • HTML
The querySelector method uses CSS selectors to select elements in the DOM. You can use CSS selector syntax to specify the elements you want to select, making it a powerful tool for finding and manipulating DOM elements based on their attributes and structure.

Which of the following is NOT a primitive data type in JavaScript?

  • Object
  • Number
  • String
  • Function
In JavaScript, primitive data types include Number, String, Boolean, Null, Undefined, and Symbol. Object is not a primitive data type; it is a reference data type that can hold collections of key-value pairs or functions. Primitive data types are immutable, whereas objects are mutable.

Which method is used to convert a JSON response to a JavaScript object?

  • parseJSON()
  • toJSON()
  • JSON.parse()
  • stringifyJSON()
The correct method to convert a JSON response to a JavaScript object is JSON.parse(). JSON.parse() parses a JSON-formatted string and turns it into a JavaScript object. It's commonly used when dealing with data received from APIs or when working with JSON data in JavaScript applications.

What is the impact on performance when using a while loop with a condition that evaluates an expression involving function calls?

  • High performance impact
  • Moderate performance impact
  • Low performance impact
  • No performance impact
Using a while loop with a condition that involves function calls can have a moderate performance impact. This is because the function calls are evaluated in each iteration, potentially incurring additional processing overhead. It's important to optimize such code to minimize performance issues.

How does the pop() method behave when applied on an empty array?

  • It returns undefined and does nothing
  • It throws an error
  • It removes the last undefined element and returns it
  • It returns null
When the pop() method is applied to an empty array in JavaScript, it returns undefined and does nothing to the array. There are no elements to remove, so it simply returns undefined without causing any errors.

Which object is heavily used in AJAX to interact with server-side data?

  • XMLHttpRequest
  • JSON
  • DOM
  • Console
XMLHttpRequest is a crucial object used in AJAX (Asynchronous JavaScript and XML) to make HTTP requests to the server and interact with server-side data without requiring a page reload. It allows for asynchronous communication with the server, making web applications more dynamic and responsive.

Considering JavaScript's type coercion, what will be the result of [] == ![]?

  • TRUE
  • FALSE
  • undefined
  • Throws an error
JavaScript performs type coercion when comparing values. In this case, the empty array [] is truthy, and ![] evaluates to false. When comparing, the empty array is coerced to false, resulting in true. This behavior can be surprising and is a common gotcha in JavaScript.

In what year was JavaScript introduced to the world?

  • 1990
  • 1995
  • 2000
  • 2005
JavaScript was introduced to the world in 1995. It was first released as part of Netscape Navigator 2.0. This event marked the beginning of JavaScript's journey as a popular and widely used scripting language for web development.

Unlike traditional functions, arrow functions do not have their own __________.

  • this
  • arguments
  • return
  • parameters
Unlike traditional functions, arrow functions do not have their own this binding. In arrow functions, this retains the value of the enclosing lexical context, which makes it useful in cases where you want to maintain the context of the surrounding code, such as in callbacks or when defining functions within functions.

You're debugging a JavaScript application and notice unexpected behavior in the manipulation of an array. The items are not being removed correctly using a method, and it turns out the array is not being modified at all. Which array method might be mistakenly being used?

  • pop()
  • push()
  • splice()
  • concat()
The concat() method is often mistakenly used for removing elements from an array because it doesn't modify the original array but returns a new array instead. The correct method for removing elements from an array is splice() or other methods like pop() or shift().