I am trying to learn JavaScript ES6 which is a very cool language and I thought that I should practice a bit but I am not able to make an exercise. So how can I use object literal to copy a class.
For example the class is:
class Point {
constructor(x, y) {
this.x = x, this.y = y
}
add(other) {
return new Point(this.x + other.x, this.y + other.y)
}
}
And I want to do something here using object literal to make the output true.
var fakePoint = YOUR_CODE_HERE
console.log(fakePoint instanceof Point)