Last active
March 19, 2017 10:58
-
-
Save kenmori/827295cd17d31eb35719cb825c4aca89 to your computer and use it in GitHub Desktop.
【TypeScript】__extendsやnew __()は何をやっているか
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Point { | |
x: number; | |
y: number; | |
constructor(x, y){ | |
this.x = x; | |
this.y = y; | |
} | |
add(point) { | |
return new Point(this.x + point.x, this.y + point.y); | |
} | |
log(): void{ | |
console.log("here is Point"); | |
} | |
} | |
var point = new Point(1, 1); | |
class Point3D extends Point { | |
z:number; | |
constructor(x, y, z){ | |
super(x, y); | |
this.z = z; | |
} | |
add(point){ | |
var point2D = super.add(point); | |
return new Point3D(point2D.x, point2D.y, this.z + point.z); | |
} | |
} | |
var point3d = new Point3D(5, 10, 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment