![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ts
Specialize in Linxu
代码就是不断发现问题从而解决问题!
展开
-
枚举如何使用
const enum Direction{up=“up”,down=“DOEN”,left=“LEFT”,right=“RIGHT”}const value=“up”if(value==Direction.up){debugger}原创 2021-12-22 23:58:34 · 54 阅读 · 0 评论 -
类型type-guard ----typescript
function getLength(input:number| string):number{if(typeof input==‘string’){return input.length}else{return input.toString().length}}原创 2021-12-22 22:51:26 · 662 阅读 · 0 评论 -
类型断言==typescript
function getLength(input:number| string):number{const str=input as stringif(str.length){return str.length}else{const num=input as numberreturn num.toString().length}}原创 2021-12-22 22:46:27 · 259 阅读 · 0 评论