You can use the in
operator to check if an object has a certain property. For example:
index.tsx130 chars6 lines
Alternatively, you can also use the hasOwnProperty
method to check if an object has a property that belongs to itself rather than its prototype chain. For example:
index.tsx143 chars6 lines
Remember to replace fieldName
with the actual name of the field you want to check, and myObject
with the name of the object you want to check the field on.
gistlibby LogSnag