Open In App

Lodash _.isError() Method

Improve
Improve
Like Article
Like
Save
Share
Report

Lodash _.isError() Method checks whether the given value is a type of error or not and returns the corresponding boolean value.

Syntax:

_.isError(value);

Parameters:

  • value: This parameter holds the value to be checked for error.

Return Value:

This method returns a Boolean value(Returns true if the given value is an error, else false).

Example 1: In this example, we are getting a ‘true’ value as a new Error is an object.

Javascript




// Defining Lodash variable
const _ = require('lodash');
 
// Checking for Error Value
console.log("The Value is Error : "
    + _.isError(new Error));


Output:

The Value is Error : true

Example 2: In this example, we are getting a ‘false’ value as Err is not an object.

Javascript




// Defining Lodash variable
const _ = require('lodash');
 
// Checking for Error Value
console.log("The Value is Error : "
    + _.isError("Err"));


Output:

The Value is Error : false 

Last Updated : 03 Nov, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads