Open In App

Lodash _.isObjectLike() Method

Last Updated : 04 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Lodash _.isObjectLike() method is used to find whether the given value is object-like or not. It returns a True if the given value is object-like which means if it's not null and has a type of the result of "object". Otherwise, it returns false.  

Syntax:

_.isObjectLike(value);

Parameter:

  • value: This parameter holds the value to check.

Return Value:

  • This method returns true if the value is object-like, else false.

Example 1: In this example, we are checking whether the given value is an object or not by the use of the lodash _.isObjectLike() method.

javascript
// Requiring the lodash library  
const _ = require("lodash");

// Use of _.isObjectLike() method 
// When the value declare as an object  
console.log(_.isObjectLike({}));

// When the value is null
console.log(_.isObjectLike(null)); 

Output:

true
false

Example 2: In this example, we are checking whether the given value is an object or not by the use of the lodash _.isObjectLike() method.

javascript
// Requiring the lodash library  
const _ = require("lodash");

// Array object
let arr = [1, 2, 3];

// Use of _.isObjectLike() method 
console.log(_.isObjectLike(arr));

Output:

true

Example 3: In this example, we are checking whether the given value is an object or not by the use of the lodash _.isObjectLike() method.

javascript
// Requiring the lodash library  
const _ = require("lodash");

// The source object
let info = {
    Name: 'GeeksforGeeks',
    password: 'gfg@1234',
    username: 'your_geeks'
}

// Use of _.isObjectLike() method 
console.log(_.isObjectLike(info));

Output:

true

Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.


Next Article

Similar Reads