In Linux, the ________ command can be used to see who has been granted sudo access.

  • sudoers
  • whoami
  • visudo
  • su
In Linux, the visudo command is used to see who has been granted sudo access. This command opens the sudoers file in a safe manner for editing and displays the sudo configuration. It's important to use visudo to avoid syntax errors in the sudoers file, which could lock you out of administrative access.

Which command can be used to list currently loaded kernel modules?

  • lsmod
  • modprobe
  • modinfo
  • insmod
The command 'lsmod' is used to list currently loaded kernel modules in Linux. This command displays a list of all the kernel modules that are currently loaded into the running kernel.

You are reviewing a junior developer's code and see the following line var x = 10;. You want to advise them to use a declaration that maintains block scope, which keyword should they use instead of var?

  • let
  • const
  • block
  • scope
Instead of var, they should use let to maintain block scope. var has function scope and can lead to unexpected behavior in certain situations, while let declares a variable with block scope, ensuring that it's limited to the block in which it's defined.

An async function can contain an await expression that pauses the execution of the async function and waits for the passed _______ to resolve or reject.

  • callback
  • timeout
  • Promise
  • generator
An async function can contain an await expression that pauses the execution of the async function and waits for the passed Promise to resolve or reject. This allows for more readable and sequential asynchronous code, making it easier to work with asynchronous operations.

What does the keyword "new" do in JavaScript?

  • Creates a class
  • Declares a variable
  • Instantiates an object
  • Defines a function
The keyword "new" in JavaScript is used to instantiate an object from a class constructor. When you use "new" followed by a class constructor, it creates a new instance of that class, allowing you to work with objects that have the properties and methods defined in the class. It doesn't create a class, declare a variable, or define a function.

The mechanism that allows you to use the structure of a class and alter it for use in another class is known as _________.

  • Inheritance
  • Polymorphism
  • Encapsulation
  • Abstraction
The mechanism that allows you to use the structure of a class and alter it for use in another class is known as "Inheritance." Inheritance in JavaScript is achieved through the prototype chain, where a child class can inherit properties and methods from a parent class, allowing for code reuse and extension.

Imagine you're reading a book about the history of web development. The chapter on JavaScript mentions a language that was developed almost simultaneously and competed with JavaScript in the early days. What is the name of this language?

  • LiveScript
  • CoffeeScript
  • TypeScript
  • ActionScript
In the early days of web development, there was another language called "LiveScript" that was developed almost simultaneously with JavaScript. Although they had similar names, they were different languages. Eventually, LiveScript was renamed to JavaScript.

You've encountered a do-while loop in a codebase which seems to execute one unnecessary iteration. What might be a possible reason for using do-while in this instance, and what could be an alternative solution?

  • The loop is used for input validation.
  • The loop is intended to run until a specific condition is met.
  • The loop is used for counting items in an array.
  • The loop is intended for asynchronous operations.
A common use of do-while loops is for input validation, ensuring that a specific task is performed at least once before checking the condition. The unnecessary iteration might occur because the loop is designed to prompt the user for input before evaluating the condition. An alternative solution could be to use a while loop with the condition checked before the loop, but it wouldn't guarantee at least one execution.

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.

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.

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.

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.