JSFiddle - React, Tailwind, and code Playground
JavaScript
function Point(x, y) {
this.x = x;
this.y = y;
this.clone = function () {
var newPoint = {};
for (var key in this) {
newPoint[key] = this[key];
}
return newPoint;
};
};
var p1 = new Point(2, 3);
var p2 = p1.clone();
p1.x = 6;
alert(p1 != p2); //first assertion. pseudocode.
alert(p2.x == 2); //second assertion. pseudocode.