Aug 8, 2024
61_error_object
try {
console.log(harry);
} catch (error) {
console.log(error.name); // Outputs: ReferenceError
console.log(error.message); // Outputs: "harry is not defined"
}
throw new Error("Harry is not good");
throw new ReferenceError("Harry is not good");
let age = prompt("Enter your age");
age = Number.parseInt(age);
if (age > 120) {
throw new Error("This is probably not true");
}
try {
// code that may throw an error
} catch (error) {
console.log(error.message);
console.log(error.stack);
}
replit.com/@codewithharry
.