Conditionally add properties inside Object in Javascript
const cond = false;
const obj = {
...(cond ? {a: 1} : {}),
b: 2,
};
// {b: 2}
const cond = false;
const obj = {
...(cond ? {a: 1} : {}),
b: 2,
};
// {b: 2}
Article 2024-11-04
Article 2024-11-04 Standards Website Footer Copyright Bar Copyright © 2024…
Article 2024-11-04
When creating dynamic components in angular applications or writing tests,…
References: