How to Clone An Object in Javascript
Posted on: February 18, 2021 by Ariessa Norramli
In this article, you will learn how to clone an object in Javascript.
Let’s say you have an object named ‘a’.
var a = { name: "code-source.tempurl.host" };
In order to clone an object, you can use the spread syntax ...
.
var a = { name: "code-source.tempurl.host" };
var b = { ...a };
console.log(a);
console.log(b);
Note: The spread syntax ...
functions by shallow copying the properties and values of an object to another.
Share on social media
//