In nodejs 8.10 I want a function to return a different object depending on parameters. Is there any simple way to include or not a key based on its value?
Example
// I do not like this solution, there is a 2 line body
// `c` may be undefined or a string (for example)
const f = (a, b, c) => {
if (c) return ({ a, b, c });
else return { a, b }
}
Can we do a simple return with c
included or excluded based on its value?
I expect something like this:
// I expect this kind of solution.
const f = (a, b, c) => ({ a, b, ___????___ })