Monday, June 15, 2026
HomeLanguagesJavascriptUnderscore.js _.isError() Function

Underscore.js _.isError() Function

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




<!DOCTYPE html> 
<html
  <head
    <script src =  
    </script
   </head
  <body>
    <script>
      let e=new Error()
      let ans=_.isError(e)
      console.log(_.isError(e))
      if(ans)
      console.log("It is the javascript error")
    </script>
  </body
</html>


Output:

Example 2: When try catch is used to throw error.




<!DOCTYPE html> 
<html
  <head
    <script src =  
    </script
   </head
  <body>
    <script>
      let e;
      try{
        alrt("neveropen")
      }
      catch(e){
        let ans=_.isError(e)
        console.log(`Error is ${e}`)
        console.log(_.isError(e))
        if(ans)
        console.log("It is the javascript error object")
      }
    </script>
  </body
</html>


Output:

Example 3: When given error is string type.




<!DOCTYPE html> 
<html
  <head
    <script src =  
    </script
   </head
  <body>
    <script>
      let e="some error"
      let ans=_.isError(e)
      console.log(_.isError(e))
      if(ans)
      console.log("It is the javascript error object")
      else
      console.log("It is not the javascript error object")
    </script>
  </body
</html>


Output:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS