I have a lot of variables that are already defined:
var listOfCars = $('#cars');
var car = $('#currentCar');
var carIndex = $(car).index();
var isFirstCar = carIndex == 0;
var isLastCar = carIndex == $(listOfCars).length - 1;
// and many more in real life
And I want to put all of them into an object where the name of the variable is also the name of the key. This is how I would do it if I wanted to rewrite every line:
var params = {
listOfCars : listOfCars,
car : car,
...
};
With Sublime I was able to create an array of variable names:
var paramKeys = [ "listOfCars", "car", "carIndex"...];
But I'm stuck on how to assign the actual values easily. I'm hoping to find a one-liner. Something like this:
paramKeys.every( key => param[key] = ????? );