TypeScript笔记
作者:互联网
TypeScript的最大特点:
1、提供了强数据类型:
1、提供了强数据类型:
变量定义:声明类型 let name:string = "你好, ts"; let num:number = 120; let isOk:boolean = true;
let arr:number[] = [1,2,3,5]; let arr:string[] = ['1', '2']; //数组 let arr:any[] = ['1', 2, undefined, true]; let arr:Array<number> = [1,2,3,5]; let arr:Array<string> = ['1', '2']; let arr:[string, number, boolean] = ['1', 2, true]; //元组类型
let name:string|number; //联合类型
let arr:number[]|string[];
函数定义:参数:声明类型,返回值:声明类型 function (name:string, age?:number):string{ return name=="jack"? "Yes":"No"; }
2、新增:枚举、元组、接口、命名空间、
标签:arr,TypeScript,string,number,笔记,let,true,name 来源: https://www.cnblogs.com/feiying100/p/16687907.html