Modules
Buat file index.js, person.js dan teacher.js\
index.js
import { Teacher } from "./teacher";
const teacher = new Teacher("Rajif", "S.Kom");
teacher.teach()
person.js
export class Person {
constructor(name) {
this.name = name;
}
walk() {
console.log("walk")
}
}
teacher.js
import { Person } from './person';
export class Teacher extends Person {
constructor(name, degree) {
super(name);
this.degree = degree;
}
teach() {
console.log("tech")
}
}
Last updated
Was this helpful?