typescript 学习

类型判断:

    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);
    }

猜你喜欢

转载自www.cnblogs.com/yc-c/p/9087890.html