From the course: TypeScript: Object-Oriented Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Methods with TypeScript

Methods with TypeScript

From the course: TypeScript: Object-Oriented Programming

Start my 1-month free trial

Methods with TypeScript

- [Instructor] All right. Let's dive into methods. Methods are nothing more than functions that belong to our classes. Let's check out a little bit of our setup here. You see we have a title for a new course. I've sent out numerous sort of email promotions for my own courses, as well as for businesses. So you might get something like a title, "Hey, you know, new course, just 9.99." And then in the content you get a, "Oh, check out the latest course on object oriented program with TypeScript." Now let's say that we had a preview message method, which all it would do would take the first 10 characters of our message here and then put ... to sort of intrigue you. What would that look like in TypeScript? So we'll start off by writing a previewMessage and we're not going to have any parameters on here, but what we are going to have is a return type of a string. So much like how our properties and our parameters can have type…

Contents