Answer the question
In order to leave comments, you need to log in
How to check if a property exists in a class?
I want to check a property in a class and set its value to ?
export class Test {
public name: string;
public type: string;
constructor(props) {
Object.keys(props).map(item => {
if(this.hasOwnProperty(item)) {
this[item] = props[item]
}
})
}
}
const test = new Test({ name: 'Dima' });
console.log(test);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question