三种变量类型:
string
number
bool
字符串 需要用单引号引起来
存储的时候 后面存的内容,需要和前面的内容对应
let title:string = '巨无霸汉堡'( 如果写 123 则会报错)
console.log('字符串title' , title)
let age:number=18
console.log('年级age' , age)
age = 90
console.log('年级age' , age)
let isLogin:boolean = true (true/false)
console.log('是否登录成功' , isLogin)
热更新:

常量(不可变):
const 常量:类型 = 值
const companyName : string = '华为'
console.log('公司名':companyName )
变量不能使用- ,但可以使用_;不能以数字开头;
严格区分大小写;
数组
let 数组名:类型[] = [数据1,数据2,... ]
let names:string[] = ['james','Tom', 'Mark']
函数
function buy(price:num , num:number)
{
return result;
}
箭头函数
let 函数名()=>{
}
对象


联合类型
枚举类型




4827

被折叠的 条评论
为什么被折叠?



