Friday, October 10, 2025
HomeLanguagesJavascriptLodash _.unset() Method

Lodash _.unset() Method

The Lodash _.unset() method is used to remove the property at the path of the object. If the property is removed then it returns True value otherwise, it returns False.

Syntax:

_.unset(object, path)

Parameters: This method accepts two parameters as mentioned above and described below:

  • object: This parameter holds the object to modify.
  • path: This parameter holds the path of the property to unset. It can be an array or string.

Return Value: This method returns true if the property is deleted, else false. 

Example 1:

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
  
// The source object 
var obj = { 'cpp': [{ 'java': { 'python': 3 } }] };
  
// Use of _.unset() method
console.log(_.unset(obj, 'cpp[0].java.python'));
  
// Object is modified
console.log(obj);


Output:

true
{ cpp: [ { java: {} } ] }

Example 2:  

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
  
// The source object 
var obj = { 'cpp': [{ 'java': { 'python': 3 } }] };
  
// Use of _.unset() method
console.log(_.unset(obj, ['html', 'css', 'javascript']));
  
// Object
console.log(obj);


Output:

true
{ cpp: [ { java: [Object] } ] }

Note: This will not work in normal JavaScript because it requires the library lodash to be installed and can be installed using npm install lodash..

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32349 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6715 POSTS0 COMMENTS
Nicole Veronica
11878 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6837 POSTS0 COMMENTS
Ted Musemwa
7097 POSTS0 COMMENTS
Thapelo Manthata
6792 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS