Functions Introduction # Functions are the fundamental building block of any application in JavaScript. They’re how you build up layers of abstraction, mimicking classes, information hiding, and modules. In TypeScript, while there are classes, namesp…
怎么定义TypeScript呢? TypeScript是一个工具 是一个编译器 编译代码 TypeScript,通过它的能力,默认使用tsc命令,可以根据.ts为后缀名的文件生成一个新的js文件 2.类型注解 TypeScript里的类型注解是一种轻量级的为函数或变量添加约束的方式.TypeScript提供了静态的代码分析,它可以分析代码结构和提供的类型注解. function doSth(who: string): string { return "I want to say hello to…
Generic Fucntion: For example we have a set of data and an function: interface HasName { name: string; } const heros: HasName[] = [ {name: 'Jno'}, {name: 'Miw'}, {name: 'Ggr'}, {name: 'Gew'}, {name: 'Wfe'} ]; function cloneArray(ary: any[]): any[] {…