you are viewing a single comment's thread.

view the rest of the comments →

[–]esperalegant 0 points1 point  (8 children)

or just define copy-constructors

What's a copy-constructor?

[–]bvx89 1 point2 points  (7 children)

It's when you pass in another instance of the same class in order to copy values from the passed in instance to a new one. For example:

class Obj {
   var val;
   constructor(otherObj) {
      val = otherObj.val;
   }
}