<script type="text/JavaScript">
class Worker {
constructor(age, salary) {
this.age = age;
this.salary = salary;
}
get calc() {
return this.calcYearlySalary();
}
calcYearlySalary() {
return this.salary * 12;
}
}
const w = new Worker(43, 12900);
document.write(w.calc);
/*
run:
154800
*/
</script>