קורס Front-End Web Development שיעור תחביר מחלקות ב JavaScript


זה נושא דיון מלווה לערך המקורי ב- https://www.tocode.co.il/bundles/html5-web-development/lessons/oojs-syntax
answer 1
// Fill Code Here
function Person(name){
  this.name=name;
  this.year=1;
}
Person.prototype.growUp=function() {
  this.year +=1;
}
Person.prototype.hello=function() {
  log("My name is "+this.name +" and I am "+ this.year +" years old");
}

לייק 1
answer 2
// Write Code Here
function Summer() {
  this.total=0;
}

Summer.prototype.add=function(num) {
  this.total +=num;
}
Summer.prototype.getCurrentSum=function() {
  return this.total;
}
לייק 1