Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 732 Bytes

what_are_the_applications_of_assign_method.md

File metadata and controls

18 lines (12 loc) · 732 Bytes

What are the applications of assign method?

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