Using getters to create read-only properties

We don't always want a property to be writable. In previous recipes, we saw how to create a read-only property on an object. In this recipe, we'll see how to use the get keyword to do this in the context of a class body.

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.