Variables, Let, Constant
var names = 'typescript';
console.log(names)
var names = 'react'
console.log(names)
let names = 'typescript'
console.log(names)
names = 'cit'
console.log(names)
const names = 'typescript'
console.log(names)
Boolean
let isDone: boolean = false;
console.log(typeof(isDone))
Number
// number
let decimal: number = 6;
// console.log(typeof(decimal))
let hex: number = 0xf00d;
let binary: number = 0b1010;
let octal: number = 0o744;
String
//string
let color: string = 'blue';
color = 'red';
console.log(color)
let fullname: string = `Steve Jobs`
let age: number = 45;
let sentence: string = `Hello, my name is ${fullname}
I'll be ${age + 1} years old next year.
`
console.log(sentence);
let sentence: string = "Hello, my name is " + fullname + ".\\n" +
"I'll be " + (age+1) + " next year."
console.log(sentence);
Array
let list: number[] = [1, 2, 3];
let list: Array<number> = [1, 2, 3; ]
console.log(typeof(list));
Tuple
// tuple
let x: [string, number];
x = ['hello', 10];
console.log(x);
console.log(x[0].substring(1));
Enum
// Enum
enum Color{Red, Green, Blue}
enum Color{Red = 1, Green = 2, Blue = 3}
let c: Color.Green;
Any
// Any
let notSure: any = 4;
notSure = 'hmmm';
notSure = false;
Null & Undefined
// Null & Undefined
let u: undefined = undefined;
let n: null = null;
Void
// Void
function warnUser(): void {
console.log("Warning message")
}
console.log(warnUser);