Lodash _.unescape() Method

Last Updated : 25 Oct, 2023

Lodash _.unescape() method is used to convert HTML entities like &, <, >, " and ' in the given string to their corresponding characters.

Syntax:

_.unescape(string);

Parameter:

  • string: It is the string to be used for unescaped.

Return Value:

This method returns the unescaped string.

Example 1: In this example, we are converting HTML entities into corresponding characters by the use of the _.unescape() method.

JavaScript
// Defining Lodash variable 
const _ = require('lodash');

// The string to unescape
let str = "fit & fine";

// Using _.unescape() method
console.log(_.unescape(str));

Output:

fit & fine

Example 2: In this example, we are converting "Heyy" into corresponding characters by the use of the _.unescape() method.

JavaScript
// Defining Lodash variable 
const _ = require('lodash');

// The string to unescape
let str = ""Heyy"";

// Using _.unescape() method
console.log(_.unescape(str));

Output:

"Heyy"
Comment