title: Looking for shorthand to insert a variable into object if not null
body: <p>Often I have several named variable, and I want to put them into an object if they are not null or undefined. JavaScript has several nice shortcuts for building objects, so I figure there must be one for this use case.</p>
  <p>I usually do something like this. But it is so verbose.</p>
  <pre><code>function foo(a, b) {
    return {...(isNotNullish(a) ? {a} : {}), ...(isNotNullish(b) ? {b} : {})};
  }
  // the result I want is:
  // foo(6, 7) == {a: 6, b: 7}
  // foo(6) == {a: 6}
  // foo() == {}
  </code></pre>
  <p>Is there a better way?</p>