PetrIII,
let data = [{
val1: 0,
val2: 0,
val3: 0,
year: "2018"
}, {
val1: 1,
val2: 1,
val3: 1,
year: "2019"
}];
let arr = data.reduce((obj, elem) => {
let {year, ...el} = elem;
for (let key in el) {
let ob = obj[key];
if (!ob) {
ob = obj[key] = {Name: key};
obj.arr.push(ob)
};
ob[year] = el[key];
};
return obj;
}, {arr: []}).arr
console.log(arr)