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
What are static methods and how should they be used? Watch this video to find out!
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
In this video I'll show you what a static
method is and how they can be useful.
0:00
And if you'd like to follow along
open the workspace for this video.
0:00
A static method is one that exist
on the class decoration and
0:03
is not accessible through an instance.
0:08
You can only call the function
by referencing it's class.
0:10
In the file static.js I have
a bird class with a static method
0:13
called change color and
by default the color is set to red.
0:17
Now the interpreter knows
this is a static function
0:22
because the line starts
with the static keyword.
0:25
So let's see how this works.
0:28
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