TransWikia.com

Is there any way to check if a typescript class has a property?

Stack Overflow Asked by Branko Simovic on November 22, 2021

Let’s say i have a class like this:

export class Test{
  public prop: string;
}

and at the start, I call

const obj = new Test(); 

is there any way that I can see what properties I have on the Test model without assigning the properties,
I tried this but it does not work

console.log(obj.hasOwnProperty('prop')) 

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP