Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 326 Bytes

File metadata and controls

20 lines (15 loc) · 326 Bytes

Use default arguments instead of short circuiting or conditionals

Default arguments are often cleaner than short circuiting.

Bad:

function loadPages(count?: number) {
  const loadCount = count !== undefined ? count : 10;
  // ...
}

Good:

function loadPages(count: number = 10) {
  // ...
}