Complete the code to create a fresh object literal assigned to obj.
const obj = [1];Using {} creates a fresh empty object literal in TypeScript.
Complete the code to assign obj2 to the same object as obj1.
const obj1 = {};
const obj2 = [1];Assigning obj2 = obj1 makes both variables reference the same object.
Fix the error in the code to correctly copy properties from source to target without sharing the same object.
const source = { a: 1 };
const target = [1];
// Now target and source are separate objectsUsing the spread operator { ...source } creates a fresh object copying properties from source.
Complete the code to create a new object copy with all properties from original and add a new property id with value 5.
const original = { name: 'Alice' };
const copy = [1] , { id: 5 };Use the spread operator inside an object literal and separate properties with a comma.
Fill all three blanks to create a fresh object result that copies data, overrides count to 10, and adds a method show that logs count.
const data = { count: 3 };
const result = {
[1],
count: [2],
show() { console.log(this.[3]); }
};data.count inside the method instead of this.countSpread data to copy properties, override count with 10, and use this.count inside the method to access the property.