Thursday, October 23, 2025
HomeLanguagesJavascriptUnderscore.js _.isSymbol() Function

Underscore.js _.isSymbol() Function

Underscore.js is a library in javascript that makes operations on arrays, string, objects much easier and handy. _.isSymbol() function is used to check whether the given object is javascript Symbol 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 global variable.

Syntax:

_.isSymbol(object);

Parameters: It takes only one parameter i.e object.

Returns: It returns the boolean value. If the object is a Symbol object of javascript it returns true otherwise false is returned by the function.

Few Examples are given below for better understanding of the function.

Example 1: When symbol is created with some value.

HTML




<!DOCTYPE html> 
<html
  <head
    <script src =  
    </script
   </head
  <body>
    <script>
      //creating new symbol from symbol object
      let e=Symbol("some symbol")
      let ans=_.isSymbol(e)
      console.log("symbol is :", e)
      console.log(_.isSymbol(e))
      if(ans)
      console.log("It is the javascript Symbol Object")
      else
      console.log("It is the not javascript Symbol Object")
    </script>
  </body
</html>


Output:

Example 2: When a symbol is created with no given object

HTML




<!DOCTYPE html> 
<html
  <head
    <script src =  
    </script
   </head
  <body>
    <script>
      //creating new symbol from symbol object
      let e=Symbol()
      let ans=_.isSymbol(e)
      //printing the symbol
      console.log("symbol is :", e.valueOf(e))
      //printing true if this is the symbol else false
      console.log(_.isSymbol(e))
      if(ans)
      console.log("It is the javascript Symbol Object")
      else
      console.log("It is the not javascript Symbol Object")
    </script>
  </body
</html>


Output:

Example 3: When a given object is the string.

HTML




<!DOCTYPE html> 
<html
  <head
    <script src =  
    </script
   </head
  <body>
    <script>
      //creating new string
      let e="neveropen"
      let ans=_.isSymbol(e)
      //printing the symbol
      console.log("symbol is :", e.valueOf(e))
      //printing true if this is the symbol else false
      console.log(_.isSymbol(e))
      if(ans)
      console.log("It is the javascript Symbol Object")
      else
      console.log("It is the not javascript Symbol 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
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS