From the course: TypeScript: Object-Oriented Programming
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Static
- [Instructor] Let's talk a little bit about the static access modifier. At its core what it means is that we can only access ether a property of a method of a class, not having it instantiated. And it sort of becomes a utility function to a degree. That's really how I think of static methods and properties. Is they're there for context, they provide a utility. And we use them, but we don't actually instantiate them. That's the intent. So let's give an example. I'll even go a little bit deeper and give an example of how we can do some cool object-oriented programming implementation to give you an idea of how you might use static methods. So if you remember earlier we have our Message class that we defined. And now we have this Messages, which you would imagine would be an array of Messages. Now let's say we wanted to create a static method. We can with the keyword static and let's say we want to return the valid…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.