typescript string code example
Example 1: typescript integer
const myInt: number = 17;
const myDecimal: number = 17.5;
Example 2: typescript array of objects
interface Product {
name: string;
price: number;
description: string;
}
let pen: Product = {
name: "Pen",
price: 1.43,
description: "Userful for writing"
}
let products: Product[] = [];
products.push(pen);
console.log(products);
Example 3: use type as value typescript
Typescript interfaces aren''t being compiled into the js output, and you can not use them at runtime
Example 4: typescript array
let list: number[] = [1, 2, 3];