Administrator
发布于 2024-04-28 / 10 阅读
0
0

入门typescript-基本数据类型

let msg:string ="hello world" ;
console.log('msg:'+ msg);

let num:number=21;
console.log('num:'+num);

let finished: boolean =true;
console.log('finished:'+ finished);

let a:any='jack';//任意类型
a = 20;
console.log('any a:'+a)


let ext :number|string ="dba" //联合类型

let p = {name:'Jack',age:21}//匿名类型
console.log(p.name)
console.log(p['age'])

let names:Array<string>= ['Jack','Rose'];
let ages:number[]=[21,18]
console.log(names[1]);
console.log(ages[1])


评论