Implement lodash's `.get` method
In this article, We will try to implement basic funtionality of lodash's `.get` method
In this article, we will try to implement basic funtionality of lodash's .get
method. We will impolement getValue
function
that will take an array of Object
and a path string
as arguments. It will returns the value of path in object.
** For Example**:
What is lodash _.get() ?
Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.
** Arguments of lodash's .get
method **
object (Object)
: The object to query.
path (Array|string)
: The path of the property to get.
[defaultValue] (*)
: The value returned for undefined
resolved values.
Returns
Returns the resolved value.
Lets Implement getValue()
function
Before implementation we are going to make few assumptions.
getValue()
will not access value in array
Javascript Implementation
More Articles
Deploying Next.js Apps
How to deploy your Next.js apps on Vercel.
January 2, 2023
How to show CHANGELOG page in storybook of react, typescript project
In this blog post, we'll go over the steps for showing a CHANGELOG page in your Storybook instance. By the end, you'll have a clear understanding of how to set this up and keep your CHANGELOG up to date.
December 20, 2022