基本类型

类型初始化

//"const" 用于常量,
//"let" 用于变量

//整数
let num: number = 42, otherNumber = 37
const maxInt64 = Number.MAX_VALUE
const Mb = 1_048_576

//双精度浮点数
const exp = 2.71828
let billion = 1E+9

//单精度浮点数
const pi = 3.14

//字符串
const greeting: string = "Hello"

//多行字符串
let text = "this is some\n" +
"multiline text"

let multiLine = `this is some
multiline text`

//布尔值
const sunIsStar: boolean = true
let earthIsStar = false

//字符 "A"    
const charA = '\u0041' //'A'

let multiType: string | number = 'text'
multiType = num

console.log("Mb is", Mb)
console.log("multiType is", multiType)
console.log("charA is", charA)