//1. typeof
typeof padding === "number";
typeof padding === "string";
typeof obj === "object";
//2. instanceof
if(padder instanceof SpaceRepeatingPadder){
//do some things
}
//3. constructor.name
if(this.constructor.name=="Player"){
//do some things
}
TypeScript 判断类型
最新推荐文章于 2024-10-11 18:29:13 发布