Q:

typescript optional parameters

// Optional Parameters
sayHello(hello?: string) {
	console.log(hello);
}

sayHello(); // Prints 'undefined'

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

sayHello(); // Prints 'hello'

sayHello('world'); // Prints 'world'
2

New to Communities?

Join the community