Check if a Variable is of type Error in JavaScript-Code Examples

Radu TM

Check if a Variable is of type Error in JavaScript

JavaScript by Radu TM June 21, 2022

if (err instanceof Error) {
  console.log('🚨 Something went wrong!');
}

0

19.705

Check if a Variable is of type Error in JavaScript

JavaScript by Radu TM June 21, 2022

if (variable instanceof Error) {
  console.log("🚨 There was an error!");
} else {
  console.log("All good!");
}

0

19.705

Check if a Variable is of type Error in JavaScript

JavaScript by Radu TM June 21, 2022

if (err instanceof Error) {
  // 😱
}

0

19.705

Related JavaScript Queries

Latest JavaScript Queries

Explore code examples by categories