Provide a default value and keep a concrete type.
Section: Functions and Parameters
Use default parameters
typescript
typescript
function connect(host = "localhost", port = 5432) {
return `${host}:${port}`;
}Explanation
Default parameters often remove the need for manual undefined handling.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Functions and Parameters