类型判断:
typeJudge() { //typeof 用来判断变量类型 var s: string = 'egret'; var isString: boolean = typeof s === 'string'; console.log(typeof s === 'string'); console.log(typeof s === 'number'); console.log(typeof s === 'any'); console.log(typeof s === 'array'); //instanceof 用来判断方法或者接口类型 var a: A = new A(); console.log(a instanceof A); console.log(a instanceof B); }