Object.assign()
is used to copy properties from one or more source objects to a target object. It can be used for cloning objects or merging multiple objects into one.
Example:
const target = { name: 'John' };
const source = { age: 30 };
const result = Object.assign(target, source);
console.log(result); // { name: 'John', age: 30 }
Tags: basic, JavaScript, objects
URL: https://www.tiktok.com/@jsmentoring/photo/7458036822975712544