클래스
클래스
class Point {
x: number
y: number
constructor(x: number, y: number) {
this.x = x
this.y = y
}
add(point: Point) {
return new Point(this.x + point.x, this.y + point.y)
}
}
var p1 = new Point(0, 10)
var p2 = new Point(10, 20)
var p3 = p1.add(p2) // {x:10,y:30}상속
정적인
접근 수식어
Abstract
Constructor is optional
constructor 사용방법
Property 초기화
Last updated