Thursday, November 20, 2025
HomeLanguagesJavascriptLodash _.toString() Method

Lodash _.toString() Method

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.

The _.toString() method is used to convert the given value to a string. An empty string is returned for null and undefined values. The sign of the value -0 is preserved.

Syntax:

_.toString( value )

Parameters: This method accepts a single parameter as mentioned above and described below:

  • value: This parameter holds the value to convert.

Return Value: This method returns the converted string.

Example 1:

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
      
// Use of _.toString() method 
console.log(_.toString(-0)); 
console.log(_.toString(['html', 'css', 'javascript']));


Output:

'-0'
'html,css,javascript'

Example 2:  

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
      
// Use of _.toString() method
  
// Will print an empty string
console.log(_.toString(null)); 
console.log(_.toString([1, 2, 3]));


 
Output:

''
'1,2,3'
RELATED ARTICLES

Most Popular

Dominic
32404 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6776 POSTS0 COMMENTS
Nicole Veronica
11925 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11994 POSTS0 COMMENTS
Shaida Kate Naidoo
6905 POSTS0 COMMENTS
Ted Musemwa
7160 POSTS0 COMMENTS
Thapelo Manthata
6861 POSTS0 COMMENTS
Umr Jansen
6846 POSTS0 COMMENTS