Tony
0
Q:

typescript default parameter

// Default Parameters
sayHello(hello: string = 'hello') { 
    console.log(hello); 
}

sayHello(); // Prints 'hello'

sayHello('world'); // Prints 'world'
5
// Default Parameters
sayHello(hello: string = 'hello') {
  console.log(hello);
}

sayHello(); // Prints 'hello'

sayHello('world'); // Prints 'world'
2
function sayName({ first, last = 'Smith' }: {first: string; last?: string }): void {
  const name = first + ' ' + last;
  console.log(name);
}

sayName({ first: 'Bob' });
1

New to Communities?

Join the community