Underscore.js _.isError() Function (original) (raw)
Last Updated : 25 Nov, 2021
Underscore.js is a library in javascript that makes operations on arrays, string, objects much easier and handy. _.isError() function is used to check whether the given object is javascript Error Object or not.
Note: It is very necessary to link the underscore CDN before going and using underscore functions in the browser. When linking the underscore.js CDN The "_" is attached to the browser as a global variable.
Syntax:
_.isError(object);
Parameters: It takes only one parameter i.e object.
Returns: It returns the boolean value. If the object is a inherit from Error object of javascript it returns true otherwise false is returned by the function.
Few Examples are given below for a better understanding of the function.
Example 1: When error is created from error object
html `
`
Output:
Example 2: When try catch is used to throw error.
html ``
``
Output:
Example 3: When given error is string type.
html `
`
Output: