Thursday, July 4, 2024
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!

Nokonwaba Nkukhwana
Experience as a skilled Java developer and proven expertise in using tools and technical developments to drive improvements throughout a entire software development life cycle. I have extensive industry and full life cycle experience in a java based environment, along with exceptional analytical, design and problem solving capabilities combined with excellent communication skills and ability to work alongside teams to define and refine new functionality. Currently working in springboot projects(microservices). Considering the fact that change is good, I am always keen to new challenges and growth to sharpen my skills.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments