Issue
I have a nested form. I want to validate it recursively. While validating, I need to check whether the object is of type Formcontroller or not. When trying instance of or type of, I am getting it as an object, not the form controller. Kindly help to find this.
Solution
If you want to know if an object is of a certain type, I believe you could ask something like this:
person = {
id: 1,
name: 'John',
age: 46,
active: true
};
house = {
color: 'blue with white patterns',
years: 20,
isInGoodCondition: true
};
const myArray = [person, house];
myArray.forEach((element) => {
if (element?.name) console.log('It is a person object');
if (element?.isInGoodCondition) console.log('It is a house object');
});
The object?.property
asks safely if that property
exists inside your object.
Answered By - Andres2142
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.