Contact: aviboots(AT)netvision.net.il
40,758 questions
53,129 answers
573 users
function sum(x: number = 3, y: number = 8): number { return x + y; } console.log(sum(4, 13)); // 4 + 13 console.log(sum(5)); // 5 + 8 console.log(sum()); // 3 + 8 /* run: 17 13 11 */
const calculateArea = (length: number, width: number = 10): number => { return length * width; }; console.log(calculateArea(5)); // 5 * 10 console.log(calculateArea(5, 20)); // 5 * 10 /* run: 50 100 */
const func = (id: number = 657321, name: string = 'R2D2'): void => { console.log(`${id} : ${name}`); }; func(); func(9999); func(8888, 'Harry'); func(undefined); /* run: "657321 : R2D2" "9999 : R2D2" "8888 : Harry" "657321 : R2D2" */