- Part 1: Let and Const
- Part 2: Template Literals
- Part 3: Default Parameter Values
- Part 4: Arrow Functions
- Part 5: Classes
Previously, to create new objects, the new keyword was used to create a copy of an existing object. Using different approaches, it could be used as a new value based on the previous object.
Get and Set
Adding even more object-oriented functionality, ES6 also added get and set functions. These can act as a quick shorthand for properties of an object to change or return a specific or calculated value.
Now, instead of writing functions such as getX() or getY(), the shorthand get and set forms can be used.
The use of get and set, however, come with a small caveat: they override existing property names. Any existing property names with the same names as the get and set usage will produce an error.