摘要:
null 和 undefined 是 ts 中的基础类型,分别具有值 null 和 undefined,默认情况下它们是所有类型的子类型,即可以赋值给任意类型,如: let s: string = 'hello' s = null //right s = undefined // right 但当我 阅读全文
摘要:
当遇到需要告诉编译器某个值是指定类型的场景时,我们可以使用类型断言,比如这个例子: const valueList = [123, "hello"] // getValue 函数随机返回数字类型或者字符串类型 function getValue() { const num = Math.random 阅读全文