TypeScript 字面量类型
先看两端代码
let str = "hello"
const str1:string = "hello"
const str2 = "hello"
在上述代码中用let声明的变量是字符类型的
而用const 没有指定类型的话,其是字面量类型,不能随意进行变更。
先看两端代码
let str = "hello"
const str1:string = "hello"
const str2 = "hello"
在上述代码中用let声明的变量是字符类型的
而用const 没有指定类型的话,其是字面量类型,不能随意进行变更。