The isset
function is not a part of the Lodash library. However, Lodash provides an _.get
function that can be used to check if a property exists on an object. Here's how you can use it in TypeScript:
index.ts214 chars14 lines
In the example above, _.get
is used to check if the foo.bar
property exists on the myObject
object. If it does, the first branch of the if statement is executed, and if it doesn't, the second branch is executed. The undefined
value is returned by _.get
if the property does not exist on the object.
Note that _.get
can also be used to retrieve nested property values. If the property you are checking is nested, you can use a dot-separated string to represent the full path to the property.
gistlibby LogSnag