ES6: Use getters and setters to Control Access to an Object - instructions

I think the instructions to this exercise could be improved.

Here is a link to my posts in the forum, regarding this exercise and the instructions: ES6: Use getters and setters to Control Access to an Object - questions

Maybe those revising/updating the curriculum can find some kernels of insight here.

I think that maybe the most important thing might be for the instructions to somehow provide an explanation to relate getters and setters to the pre ES6 ways of working with objects.

I have moved this post to a more suitable sub-forum.

Yeah, there’s always been some issues with this challenge. They’re not a terribly widely used feature of the language, mainly because JS does not prevent direct manipulation of object properties in any way. This makes it a little bit difficult to provide good examples of what the point of them is (anecdotal, but I’ve written JS professionally for about 10 years now, and I’ve never needed to use them. I’ve written code using them several times, but every time I’ve refactored them out for something more useful). YMMV. They may be useful in certain specific cases, but there are generally always other ways of writing code that doesn’t involve getters/setters.

They are maybe more useful now that JS has actual private fields for classes, but that feature is much newer than anything in the FCC curriculum (only ratified in last year), so isn’t going to make much sense to you. If you want to know more, I’d have a Google around for more examples (I realise that’s not an answer to fixing this particular challenge)

Note that getters and setters are well pre-ES6. They aren’t a feature that was added recently, they’ve been present in the language for the last 10 years or so. There isn’t any need to relate it to pre-ES6, as it’s exactly the same.

1 Like

@DanCouper, thanks for the reply and additional info. It helps to put it into perspective in the “big picture” of JS.

If getters and setters are pre-ES6, I’m curious as to why they are specifically included in the ES6 part of the curriculum, and nowhere else, as far as I can recall.

In any case, having passed the challenge and with (slightly?) better understanding of their purpose and use, the explanation of getters and setters in this challenge IMHO was “woefully inadequate.”

1 Like

They aren’t in the rest of the curriculum, so when the ES6 section was added, with challenges for the new class syntax, just slotted in there I guess.

The OO section tries to explain how OO actually works in JS at a basic level. Getters and setters don’t really fit into that part of the curriculum the way it’s currently set up, they aren’t at all important when explaining how OO works.

And they aren’t really basic JS: they aren’t particularly important, and aren’t really something that needs to be added to that section.

So that leaves them in a bit of a no-mans land; I’m not quite sure where they fit in tbqh

1 Like

Certainly async/await (ES7) is a much better topic to cover, since every cloud SDK library depends on promises, and old-school Promise chaining is really obsolete now.

But yeah, ENOTUITS