Confused by get key() { return this._key } ... please explain!

I’m reading this example:
image

But all I can find online about ‘get’ speaks about the map.get() function (eg Map.prototype.get() - JavaScript | MDN and https://www.codecademy.com/resources/docs/javascript/map/get) which uses a different syntax to the one above and seems to do a slightly different thing.

All examples I find online have an argument in the parentheses. None of them have anything before the parentheses other than ‘get’.

I’m very confused and I can’t even find any resources online that cover it! Am I searching the wrong thing?

Thank you.

Try searching for JavaScript getter or JavaScript setter.

1 Like