Q:

Build object from function parameters

I often find myself writing code like this:
function handleSomeEvent(p1, p2, p3) {
  var data =  { p1: p1, p2: p2, p3: p3 };

  //Or any other function that takes an object
  $.ajax('/url', { data: data, ... });
}

Is there a way that I can build the data object automatically from my function's parameters? 
I know that I could pass in an object instead, but sometimes it's more convenient to pass in multiple parameters (for example integrating with legacy code, or a project's existing coding style).

A:

ES2015 shorthand object literals reduce some of the repetition:
function handleSomeEvent(a, b, c) {
  console.log({ a, b, c })
}

