How is this code correct "tempObj['num']"?


In this quiz, I struggled to understand this question, but finally cannot.

let tempObj = {
  _num: 22,
  get num() {
    return this._num;

I think that tempObj[‘num’] searches ‘num’ key. So, doesn’t tempObj[‘num’] return error ?
I researched how tempObj[’_num’] works, then this code returns 22.

Could someone teach me how tempObj[‘num’] work ?

 > tempObj.num()
 X Uncaught TypeError: tempObj.num is not a function

Behind the scenes the getter is called as if we wrote, tempObj.num.


Thank you so much, I’m glad to hear that the getter is called when we write tempObj[‘num’] as if wrote tempObj.num.