Why using getter in Javascript? Seems without get before the functiontion it still work


#1

below I create a getter and a function, they return the same thing for private property.

const robot= {
  _model: '1E78V2',
  _energyLevel: 100,
  myenergyLevel: 20,
  energyLevel(){
    if(typeof this._energyLevel==='number'){
      return `My current energy level is ${this._energyLevel}`
    }else
      return'System malfunction: cannot retrieve energy level'
  },
  get energyLevelTwo(){
    if(typeof this._energyLevel==='number'){
      return `My current energy level is ${this._energyLevel}`
    }else
      return'System malfunction: cannot retrieve energy level'
  }
};
console.log(robot.energyLevel());//My current energy level is 100
console.log(robot.energyLevelTwo);//My current energy level is 100

So what is the usage of getter?
Thank you for your help!


#2

I think I get some Idea:
the keyword get and set does not call for anything but set up an instructional format that the function should perform. e.g. get function(){} need to have return.
Is this opinion correct?