TypeScript instanceof操作符缩小
语法:
x instaceof Foo
实例:
function logValue(x: Date | string) {
if (x instanceof Date) {
console.log(x.toUTCString())
} else {
console.log(x)
}
}
语法:
x instaceof Foo
实例:
function logValue(x: Date | string) {
if (x instanceof Date) {
console.log(x.toUTCString())
} else {
console.log(x)
}
}
本文标题:TypeScript instanceof操作符缩小
本文链接:https://www.haomeiwen.com/subject/dwmgfdtx.html
网友评论