Which block of code is executed regardless of whether an error is thrown or caught?
throw
catch
try
finally
What is the purpose of event.preventDefault() in form handling?
event.preventDefault()
Validates the form data
Submits the form data asynchronously
Stops the form from submitting
Clears the form fields
What does 'client-side' JavaScript refer to?
JavaScript code executed on the user's web browser
JavaScript code used for server maintenance
JavaScript code executed on a web server
JavaScript code used for database management
What is the correct syntax to add an event listener to an element?
element.addEventListener('click', functionName)
element.on('click', functionName)
element.addListener('click', functionName)
element.attachEvent('click', functionName)
Which method is used to select an HTML element with a specific ID?
querySelectorAll()
getElementbyId()
querySelector()
getElementById()
Which loop in JavaScript is best suited for iterating through the properties of an object?
while
for
for...in
do-while
Which keyword is used to declare a variable whose value should not change after its initial assignment?
const
var
static
let
What does the querySelector() method return when it finds multiple matching elements in the DOM?
null
An array of all matching elements
The first matching element
The last matching element
What is the purpose of the return keyword in a function?
return
It assigns a value to a variable.
It sends a value back from the function to the caller.
It specifies the data type of the function.
It prints a value to the console.
What is the purpose of the 'catch' block in a try...catch statement?
To handle the error thrown in the 'try' block
To execute code only if an error doesn't occur
To re-throw the caught error
To specify the type of error to catch