Inheritance and encapsulation in JS

class Lodgement {
 
  constructor (data) {
    this.square=data.square;
  }
 
  getSquare () {
    return this.square;
  } 
}
class OfficeLodge extends Lodgement {
 
  constructor (data) {
    super(data);
    this.companyName=data.name;
  }
 
  getName () {
    return 'It is a : ' + this.companyName;
  }
 
}

Inheritance

Text

Text

Inside 

Encapsulation or Keeping data private

const SimpleDate = (function() {
  let _years;

  class SimpleDate {
    constructor(year, month, day) {
      _years = year;
      this.months = month;
      this.days = day;
      
    }

    getYear() {
      return _year;
    }
  }

  return SimpleDate;

}());

І

Text

Text

Inside

Const

Here we go again

By just Just

Here we go again

  • 35