The _.valuesIn
function from lodash is a utility function used to retrieve all enumerable property values from an object. Here is an example:
index.tsx224 chars13 lines
In this example, we import the lodash library using the require
statement. We then define an object called person
with four properties. We then use the _.valuesIn
function to retrieve all property values from the person
object and store them in the values
variable. Finally, we output the values
array to the console.
Note that the _.valuesIn
function retrieves not only the values of the properties that are directly on the object, but also the values of any inherited properties from its prototype chain. This is different from the _.values
function, which only retrieves the values of the object's own properties.
gistlibby LogSnag