1// Default Parameters
2sayHello(hello: string = 'hello') {
3 console.log(hello);
4}
5
6sayHello(); // Prints 'hello'
7
8sayHello('world'); // Prints 'world'
1// Default Parameters
2sayHello(hello: string = 'hello') {
3 console.log(hello);
4}
5
6sayHello(); // Prints 'hello'
7
8sayHello('world'); // Prints 'world'
1function sayName({ first, last = 'Smith' }: {first: string; last?: string }): void {
2 const name = first + ' ' + last;
3 console.log(name);
4}
5
6sayName({ first: 'Bob' });