Lodash _.isObjectLike() Method
Last Updated :
27 Oct, 2023
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
const _ = require( "lodash" );
console.log(_.isObjectLike({}));
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
const _ = require( "lodash" );
let arr = [1, 2, 3];
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
const _ = require( "lodash" );
let info = {
Name: 'GeeksforGeeks' ,
password: 'gfg@1234' ,
username: 'your_geeks'
}
console.log(_.isObjectLike(info));
|
Output:
true
Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.
Reference: https://lodash.com/docs/4.17.15#isObjectLike
Share your thoughts in the comments
Please Login to comment...