Popular Vendors
Demo practice questions for guest users.
catch(error) {
alert("Caught error: " + error.message);}Why A is correct
UpdateRecord.jsis a JavaScript file.
- JavaScript uses the syntax
- JavaScript uses the syntax
catch(error)to handle exceptions in atry...catchblock.
error.messageretrieves the error description.Why the others are incorrect
alert()displays the error to the user.
- B ❌ Uses C#/ASP.NET syntax (
Server.GetLastError()), not JavaScript.
- C ❌ Uses incorrect Java/C#-style exception syntax and
console.writelineis not a valid JavaScript method.✅ Answer: A.
- D ❌
function(error){ console.log(error.message) }is a callback function, not acatchblock for exception handling.catch(error) {alert("Caught error: " + error.message)