Friday, June 12, 2026
HomeLanguagesJavascriptLodash _.isPlainObject() Method

Lodash _.isPlainObject() Method

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, collection, strings, lang, function, objects, numbers etc.

The _.isPlainObject() method checks if value is a plain object which means an object created by the Object constructor or one with a [[Prototype]] of null.

Syntax:

_.isPlainObject(value)

Parameters: This method accepts single parameter as mentioned above and described below:

  • value: It is the function that is used to check the value.

Return Value: This method returns true if value is a plain object else false.

Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.




// Requiring the lodash library 
const _ = require("lodash"); 
       
// Original array 
var object = _.isPlainObject(Object.create(null));
  
// Using the _.isPlainObject() method
let plain_data = ( object);
  
// Printing the output 
console.log(plain_data);


Output:

true

Example 2:




// Requiring the lodash library 
const _ = require("lodash"); 
       
// Original array 
var object = _.isPlainObject([1, 2, 3]);
  
// Using the _.isPlainObject() method
let plain_data = ( object);
  
// Printing the output 
console.log(plain_data);


Output:

false

Example 3:




// Requiring the lodash library 
const _ = require("lodash"); 
       
// Original array 
var object = _.isPlainObject({ 'x': 0, 'y': 0 });
  
// Using the _.isPlainObject() method
let plain_data = ( object);
  
// Printing the output 
console.log(plain_data);


Output:

true

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

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS