TypeScript基础——数据类型篇
为什么学习ts那?因为ts相对于js来说严格规范得多,功能越强大的产品它所需要的编程语言肯定也是越严谨的
ts中必须指定数据类型、ts是js的超集,那么js有的原始类型ts也同样具备
-
boolean类型
let bool:boolean = true;
-
number类型
let num:number = 123;
-
string类型
let str:string = "name";
-
array类型
/** * TypeScript为数组提供了专用的类型语法 * 你可以根据需求补充有效的类型声明 */ let ary:number[] = [1,2,3]; let ary1