목록클래스 (3)
taenyLog

class pet { constructor(name, age) { this.name = name; this.age = age; } eat() { return `${this.name} is eating`; } } class cat extends pet { meow() { return "mEWOOOOE"; } eat() { return `${this.name} cat eating food`; } } class dog extends pet { constructor(name, age, livesLeft = 10) { super(name, age); this.livesLeft = livesLeft; } bark() { return "VARKRKRRKK"; } } super 키워드가 super 클래스의 참조 항목이..

class cat { constructor(name, age) { this.name = name; this.age = age; } eat() { return `${this.name} is eating`; } meow() { return "mEWOOOOE"; } } class dog { constructor(name, age) { this.name = name; this.age = age; } eat() { return `${this.name} is eating`; } bark() { return "VARKRKRRKK"; } } class pet{ constructor(name, age) { this.name = name; this.age = age; } eat() { return `${this.name}..
class 생성 자바스크립트 내 클래스는 class 선언해주면 바로 생성 가능 class Polygon{ } const poly1 = new Polygon(); class 초기값 설정 constructor(생성자)이용해 class객체 초기 값 설정 가능 class 내부에서 constructor는 한개만 존재할 수 있다, constructor를 이용하여 Person클래스에 초기값 설정하기 class Polygon { constructor() { this.name = 'Polygon'; } } const poly1 = new Polygon(); console.log(poly1.name); // Expected output: "Polygon" 클래스의 인스턴스를 인스턴스화할 때마다 construcor 함수가 ..