Friday, December 27, 2024
Google search engine
HomeLanguagesJavascriptLodash _.entriesIn() Method

Lodash _.entriesIn() Method

The _.entriesIn() method is used to create an array of own and inherited enumerable string keyed-value pairs for the specified object. If object is a map or set, its entries are returned.

Syntax:

_.entriesIn(object)

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

  • object: This parameter holds the object to query.

Return Value: This method returns the key-value pairs.

Example 1:

Javascript




// Defining Lodash variable
const _ = require('lodash');
  
// Initializing a function gfg
function gfg() {
  this.a = 5;
  this.b = 10;
  this.c = 15;
}
gfg.prototype.d = 20;
  
// Calling the _.entriesIn() function
_.entriesIn(new gfg);


Output:

[ [ 'a', 5 ], [ 'b', 10 ], [ 'c', 15 ], [ 'd', 20 ] ]

Example 2: In the below code, a set is used as the object, hence the _.entriesIn() function returns its entries.

Javascript




// Defining Lodash variable
const _ = require('lodash');
  
// Initializing a set
const object = {a: {b: 5}};
  
// Calling the _.entriesIn() function
_.entriesIn(object);


Output:

[ [ 'a', { b: 5 } ] ]

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

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

Most Popular

Recent Comments