TypeScript学习笔记

TypeScript学习笔记

简介

TypeScript是微软推出的 JavaScript 的超集。

语法结构

如下

// boolean 
let isDone: boolean = false

// number
let decimal: number = 6 
let pi: number = 3.14

// string  单双引号都可以
let color: string = "blue"
color = 'red'
// 反引号可以包含多行 还可以使用${} 嵌入表达式。
let sentence: string = `Hello, my name is ${fullName}.

I'll be ${age + 1} years old next month.`;

// array 数组
let list : number[] = [1,2,3]
let list: Array<number> = [1,2,3]

// tuple 元组
// declare a tuple type 
let x: [string, number];
// Initialize it
x = ["hello", 10]; // OK
// Initialize it incorrectly
x = [10, "hello"]; // Error

 上一篇
English-2020-09 English-2020-09
English-2020-09Day: 01 单词 翻译 detach 分离,脱离 official 官方,正式 determine 确定,决定,判断 inform 通知,告知 simultaneously 同时
2020-09-01
下一篇 
Go语言知识点记录 Go语言知识点记录
Go 语言知识点记录sync包sync 是 Golang 标准库中的同步包,Once 结构中的 Do 方法能够保证传入的参数 f 只执行一次,并且在 Do 返回时 f 已经执行完成。它的源码如下: // Once is an object
2020-08-27
  目录