The try block wraps code that might fail. If an error occurs inside, JavaScript doesn't crash. Instead, it looks for a catch block to handle the error.
try {
riskyOperation();
console.log("Success");
} catch (error) {
console.log("Failed");
}
Code after the error in the try block doesn't run.