TypeScript 基础静态类型 & 对象类型

基础静态类型:number, string, boolean, null, undefinde, symbol, void

const count : number = 1;

对象类型:

const person: {
  name: string,
  age: number,
} = {
  name: "张三",
  age: 45,
};

// 数组
const persons: String[] = ["张三", "李四", "王五"];

// 类
class Person{} 
const p: Person = new Person()

// 函数
const lambda: ()=>string = ()=>{return 'lambda'}

参考:
技术胖——TypeScript从入门到精通(03. TypeScript 基础静态类型和对象类型)

posted @ 2020-12-23 15:50  qianbuhan  阅读(498)  评论(0)    收藏  举报