This course will be retired on October 31, 2026.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introducing ES2015!
You have completed Introducing ES2015!
Preview
Getter and Setter methods have long been available in objects, but now they are available in classes, too!
Resources
Want to learn more? Check out some of these resources:
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Getters and
setters give us a way of accessing and
0:00
changing data within an object.
0:01
Getters and setters are common across
programming languages like Ruby,
0:03
Java, and C#.
0:07
And ES5 already provides a way to
define getters and setters, but
0:08
the syntax is cumbersome and it often
involves creating extra utility functions.
0:11
ES2015 introduces the get and
set keywords, which provide a clean and
0:16
easier way of defining getters and
setters within a class.
0:21
We use get to retrieve and return a value
and set to assign or set a value.
0:25
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up