types typescript

Estimated reading time: 1 minute

type

# Boolean
let isDanger: boolean = true;

# number
let isDanger: number = 121;

# string
let isDanger: string = "code4mk org";

# template string
let isDanger: string = "code4mk.org";
let isResult: string = `welcome to ${isDanger}`;

# Array
let isDanger: number[] = [1, 3, 5, 7];
let isDanger: Array<number> = [1, 3, 5, 7];

# Array of objects
let employees: Array<{name: string, age: number, [key: string]: any}> = [
  { name: 'kamal', age: 26 },
  { name: 'mostafa', age: 21}
]

# Array of objects
let employees: {name: string, age: number}[] = [
  { name: 'kamal', age: 26 },
  { name: 'mostafa', age: 21}
]

# any
let isDanger: any = "this is kamal"

resources

node.js, js, typescript, ts