0

Both

function x(o) {
  return o.a + o.b
}

and

function x({ a, b }) {
  return a + b
}

are possible. What about something like this?

function x(o | { a, b }) {
  console.log('Whole thing:', o)
  return a + b
}
André Willik Valenti
  • 1,702
  • 14
  • 21

1 Answers1

1

You could move the destructuring part inside of the function.

function x(o) {
    const { a, b } = o;
    console.log('Whole thing:', o)
    return a + b;
}
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392