This is a way to rearrange object properties to the top of the property list:
const raw = {
a: 1,
b: 2,
// ...the rest
y: 3,
z: 4,
};
const templateTop = {
y: null,
z: null,
}
const rearrangedTop = Object.assign(templateTop, raw);
// {
// y: 3,
// z: 4,
// a: 1,
// b: 2,
// ...the rest
// };
However, is there a way to rearrange some properties to the bottom? I.e.
const rearrangedBottom = {
// ...the rest
y: 3,
z: 4,
a: 1,
b: 2,
};