// 变量的静态类型
// 变量:静态类型 作用:指定变量赋值为该类型的数据
// 静态类型分为:基本类型 对象类型 自定义
let test:number = 123;
// test = 'dfdsf' // bug
test = 123
let str:string = 'ds';
let bool:Boolean = true;
// :any 变量可以复制任意类型的数据。
let any:any = 123;
any = 'sdfdf';
any = [];
any = function(){}
let fun:Function = function(){}
// 深度解析:
// 变量指定静态类型时,同时具备该类型中所有API和属性
let foo:Number = 123;
let res = foo.toString()
console.log(foo);
console.log(res);
ts中static
最新推荐文章于 2024-04-25 19:45:44 发布