When looking at a random object, my goal is to verify that it follows a certain structure.
obj = {WHERE:{antherObject},OPTIONS{anotherObject}}
Once I confirm the object has the key using hasProperty(key)
, how can I retrieve the value of the key?
I thought about implementing something like this.
validateForm(obj: Object):Object {
if obj.hasOwnProperty("WHERE") {
//return the value of "WHERE"
}
else{
throw new Error("WHERE isnt a key in this object");}