clone javascript object
let clone = Object.assign({}, objToClone);
clone javascript object
let clone = Object.assign({}, objToClone);
javascript clone object
// syntax: let <newObjectName> = {...<initialObjectName>};
// example:
const me = {
name: 'Jakes',
age: 30,
};
const friend = {...me};
friend.age = 27;
console.log(friend.age); // 27
console.log(me.age); // 30
// -----------------------------
// BAD
// -----------------------------
const me = {
name: 'Jonas',
age: 30,
};
const friend = me;
friend.age = 27;
console.log(friend.age); // 27
console.log(me.age); // 30
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us