I would like to know if it's possible to avoid defining properties in a factory function. I tried using destructuring and arguments.
Let's me explain myself better. Let's suppose we have the following factory function:
const create_game = (name, artist, release) =>
({
name,
artist,
release,
load() {
console.log('Loading game...')
}
})
I already used a destructuring technique, called property value shorthand, so I don’t have to repeat myself for property assignments.
name: name,
My question is if I can go further doing some kind of magic similar to this:
const create_game = (name, artist, release) =>
({
...args,
load() {
console.log('Loading game...')
}
})
Is it possible?