multiple optional parameters typescript code example

multiple optional parameters typescript

1

1 Example

0
function addressCombo(streets: { street1?: string; street2?: string; street3?: string }) {
  console.log("street1: " + streets.street1);
  console.log("street2: " + streets.street2);
  console.log("street3: " + streets.street3);
}

addressCombo({ street1: 'A', street2: 'B', street3: 'C' });
// Log:
// street1: A
// street2: B
// street3: C

addressCombo({ street1: 'A', street3: 'C' });
// Log:
// street1: A
// street2: undefined
// street3: C
by on

Other Code Examples