typescript type of foundation
// digital type arithmetic decimal octal
let num1:number=2;
let num2:number=2+5;
let num3:number=0x2;
let num4:number=0-2;
let num5:number=0/2;
// string type supports common character string and templates
let gender:string='boy'
let username:string='iwan'
let username2:string=`iwan is good ${gender}`
// Boolean value type
let isTrue:boolean=true;
let isFalse:boolean=false;
// Data type of array type and the type of the array must be of the order of a predetermined association.
// define array types in two ways
let arr: number [] = [1,2,3] // define the element is an array type numbers only
let arr2:Array<number>=[1,2,3]
let any:any[]=[1,'2',2,true,[1,2]]
let any2: Array <any> = [1, '2', 2, true, [1,2]] // define the elements of an array may be any type
// represents a tuple allows the array element number and type of known, not necessarily the same type of elements
let x: [string, number,boolean];
x = [ 'Iwan', 5, true]