curriculum/challenges/english/blocks/quiz-debugging-javascript/66edd10913f078e7669eca81.md
To pass the quiz, you must correctly answer at least 18 of the 20 questions below.
What type of error occurs when a variable is used before it is defined?
SyntaxError
LogicalError
RangeError
ReferenceError
Which JavaScript statement can be used to intentionally pause the execution of your code for debugging purposes?
try...catch
console.log()
alert()
debugger
Which console method can be used to display data as a table?
console.log()
console.warn()
console.error()
console.table()
How can you inspect network requests in Chrome developer tools?
By using the "Network Links" tab.
By using the "Console" tab.
By using the "Sources" tab.
By using the "Network" tab.
What is the correct syntax for using try...catch in JavaScript?
try { ... } else { ... }
try { ... } stack(catch) { ... }
try { ... } error { ... }
try { ... } catch(error) { ... }
Which of the following is an example of a SyntaxError?
Using a variable before it is declared.
Using a variable twice in the same scope.
Using a variable that is out of scope.
Missing a comma between elements of an array.
What is the purpose of breakpoints in JavaScript debugging?
Automatically correct code mistakes.
Prevent code from being executed.
Log messages to the console.
Pause execution at a specific point.
What happens when the throw statement is executed?
The program terminates immediately, ignoring all remaining code.
The throw statement logs an error to the console but does not stop execution.
It pauses code execution until resumed by disabling breakpoints.
An exception is thrown and the catch block (if present) is executed.
Which method would you use to inspect variables or expressions during debugging in developer tools?
inspect()
trace()
console.error()
console.log()
What type of error will occur when the following code is executed?
function example() {
console.log(a);
let a = 5;
}
example();
FunctionError
SyntaxError
Stack overflow error
ReferenceError
Which tool is commonly used to step through code line by line during debugging?
console.log()
alert()
throw statement.
Breakpoints in Developer Tools.
What type of error occurs when attempting to access a property of undefined?
SyntaxError
LogicalError
RangeError
TypeError
What does the finally block do in a try...catch statement?
Only executes if there's an error.
Skips execution if catch is triggered.
Exits the code block immediately.
Always executes, regardless of errors.
What would be the result of running the following code?
const arr = [];
arr.length = -1;
The code will throw a SyntaxError.
The code will log an empty array to the console.
The code will throw an out of memory error.
The code will throw a RangeError.
Which of the following answers is true about the debugger statement in JavaScript?
The debugger statement is always ignored by the browser.
The debugger statement sends an error report to the server.
The debugger statement always reloads the page and clears the console.
The debugger statement is ignored when the developer tools are not open.
What is the primary purpose of "profiling" in JavaScript?
To write unit tests for JavaScript functions and create profiles of code execution.
To pause code execution and release the captured resources like memory and CPU.
To convert JavaScript code into machine code for faster execution.
To identify performance bottlenecks by recording CPU usage, function calls, and execution time.
What is a "watcher" in the context of debugging?
A tool for pausing code execution.
A built-in function for logging errors.
A JavaScript method for handling exceptions.
A tool for monitoring the value of variables.
When should you use console.error() instead of console.log()?
To display table data.
To log messages only during debugging.
To log information about the browser.
To log error messages.
What does the Error() constructor do in JavaScript?
Logs error messages to the console.
Runs code in a sandbox.
Terminates the program.
Creates a new error object that can be thrown.
What is the purpose of the console.dir() method in JavaScript?
To create a separate directory for log files for individual error type.
To generate a visual representation of the console output and save it in a pdf file.
To stop the program execution and display an error message related to memory and CPU usage.
To output a hierarchical, interactive list of properties for a specified JavaScript object.