1const first = {'name': 'alka', 'age': 21}
2const another = Object.assign({}, first);
1int serial = 123;
2MyObject thing1 = new MyObject(serial, "Name");
3thing1.addDescription("The object I plan on cloning");
4
5MyObject thing2 = thing1.clone();
6
7
8
9@Override
10public Object clone() throws CloneNotSupportedException {
11 MyObject clone = new MyObject(this.serial, this.name); // All items were immutable
12 clone.description = new String(this.description); // If a field is not immutable
13 return clone;
14}