in javascript what is ? operator code example
Example 1: ... operator javascript
let a = { a: 0, b: 1 };
let b = { b: 2, c: 3 };
let c = { ...a, ...b };
console.log(c);
output -> {a: 0, b: 2, c: 3}
Example 2: javascript ... operator
let obj1 = { foo: 'bar', x: 42 };
let obj2 = { foo: 'baz', y: 13 };
let clonedObj = { ...obj1 };
// Object { foo: "bar", x: 42 }
let mergedObj = { ...obj1, ...obj2 };
// Object { foo: "baz", x: 42, y: 13 }