Lodash _.isError() Method
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
const _ = require( 'lodash' );
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
const _ = require( 'lodash' );
console.log( "The Value is Error : "
+ _.isError( "Err" ));
|
Output:
The Value is Error : false
Last Updated :
03 Nov, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...