What is lodash.keysin?
The lodash.keysin package is a utility library that provides a method to retrieve all the enumerable property names of an object, including those inherited through the prototype chain.
What are lodash.keysin's main functionalities?
Retrieve all enumerable property names
This feature allows you to retrieve all enumerable property names of an object, including those inherited through the prototype chain. In the example, 'a' is inherited from the prototype, and 'c' is an own enumerable property.
const keysIn = require('lodash.keysin');
const object = Object.create({ 'a': 1 }, { 'b': { value: 2 }, 'c': { value: 3, enumerable: true } });
console.log(keysIn(object)); // ['a', 'c']
Other packages similar to lodash.keysin
object-keys
The object-keys package provides a method to retrieve the own enumerable property names of an object. Unlike lodash.keysin, it does not include inherited properties.
object.entries
The object.entries package provides a method to retrieve an array of a given object's own enumerable string-keyed property [key, value] pairs. It does not include inherited properties, making it different from lodash.keysin.
object.getownpropertynames
The object.getownpropertynames package retrieves all own property names of an object, including non-enumerable properties. It does not include inherited properties, unlike lodash.keysin.