A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/lodash-_-tostring-method/ below:

Lodash _.toString() Method - GeeksforGeeks

Lodash _.toString() Method

Last Updated : 25 Oct, 2023

Lodash _.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:

Return Value:

This method returns the converted string.

Example 1: In this example, we are converting the given value into the string by the use of the _.toString() method.

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: In this example, we are converting the given value into the string by the use of the _.toString() method.

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'


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4