How can I determine the type of a variable in TypeScript with Angular?
import { Component } from '@angular/core';
interface Abc {
name : string
}
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular 6';
a:Abc= {
name:"sss"
}
constructor(){
console.log(typeof this.a)
// console.log(this.a instanceof Abc)
}
}
This code snippet should provide results of true
and false